// Generated by Lisette bindgen
// Source: net/netip (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.11

pub fn AddrFrom16(addr: Slice<uint8>) -> Addr

pub fn AddrFrom4(addr: Slice<uint8>) -> Addr

pub fn AddrFromSlice(slice: Slice<uint8>) -> Option<Addr>

pub fn AddrPortFrom(ip: Addr, port: uint16) -> AddrPort

pub fn IPv4Unspecified() -> Addr

pub fn IPv6LinkLocalAllNodes() -> Addr

pub fn IPv6LinkLocalAllRouters() -> Addr

pub fn IPv6Loopback() -> Addr

pub fn IPv6Unspecified() -> Addr

pub fn MustParseAddr(s: string) -> Addr

pub fn MustParseAddrPort(s: string) -> AddrPort

pub fn MustParsePrefix(s: string) -> Prefix

pub fn ParseAddr(s: string) -> Result<Addr, error>

pub fn ParseAddrPort(s: string) -> Result<AddrPort, error>

pub fn ParsePrefix(s: string) -> Result<Prefix, error>

pub fn PrefixFrom(ip: Addr, bits: int) -> Prefix

/// Addr represents an IPv4 or IPv6 address (with or without a scoped
/// addressing zone), similar to [net.IP] or [net.IPAddr].
/// 
/// Unlike [net.IP] or [net.IPAddr], Addr is a comparable value
/// type (it supports == and can be a map key) and is immutable.
/// 
/// The zero Addr is not a valid IP address.
/// Addr{} is distinct from both 0.0.0.0 and ::.
pub type Addr

/// AddrPort is an IP and a port number.
pub type AddrPort

/// Prefix is an IP address prefix (CIDR) representing an IP network.
/// 
/// The first [Prefix.Bits]() of [Addr]() are specified. The remaining bits match any address.
/// The range of Bits() is [0,32] for IPv4 or [0,128] for IPv6.
pub type Prefix

impl Addr {
  /// AppendBinary implements the [encoding.BinaryAppender] interface.
  fn AppendBinary(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// AppendText implements the [encoding.TextAppender] interface,
  /// It is the same as [Addr.AppendTo].
  fn AppendText(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// AppendTo appends a text encoding of ip,
  /// as generated by [Addr.MarshalText],
  /// to b and returns the extended buffer.
  fn AppendTo(self, mut b: Slice<uint8>) -> Slice<uint8>

  /// As16 returns the IP address in its 16-byte representation.
  /// IPv4 addresses are returned as IPv4-mapped IPv6 addresses.
  /// IPv6 addresses with zones are returned without their zone (use the
  /// [Addr.Zone] method to get it).
  /// The ip zero value returns all zeroes.
  #[go(array_return)]
  fn As16(self) -> Slice<uint8>

  /// As4 returns an IPv4 or IPv4-in-IPv6 address in its 4-byte representation.
  /// If ip is the zero [Addr] or an IPv6 address, As4 panics.
  /// Note that 0.0.0.0 is not the zero Addr.
  #[go(array_return)]
  fn As4(self) -> Slice<uint8>

  /// AsSlice returns an IPv4 or IPv6 address in its respective 4-byte or 16-byte representation.
  fn AsSlice(self) -> Slice<uint8>

  /// BitLen returns the number of bits in the IP address:
  /// 128 for IPv6, 32 for IPv4, and 0 for the zero [Addr].
  /// 
  /// Note that IPv4-mapped IPv6 addresses are considered IPv6 addresses
  /// and therefore have bit length 128.
  fn BitLen(self) -> int

  /// Compare returns an integer comparing two IPs.
  /// The result will be 0 if ip == ip2, -1 if ip < ip2, and +1 if ip > ip2.
  /// The definition of "less than" is the same as the [Addr.Less] method.
  fn Compare(self, ip2: Addr) -> int

  /// Is4 reports whether ip is an IPv4 address.
  /// 
  /// It returns false for IPv4-mapped IPv6 addresses. See [Addr.Unmap].
  fn Is4(self) -> bool

  /// Is4In6 reports whether ip is an "IPv4-mapped IPv6 address"
  /// as defined by RFC 4291.
  /// That is, it reports whether ip is in ::ffff:0:0/96.
  fn Is4In6(self) -> bool

  /// Is6 reports whether ip is an IPv6 address, including IPv4-mapped
  /// IPv6 addresses.
  fn Is6(self) -> bool

  /// IsGlobalUnicast reports whether ip is a global unicast address.
  /// 
  /// It returns true for IPv6 addresses which fall outside of the current
  /// IANA-allocated 2000::/3 global unicast space, with the exception of the
  /// link-local address space. It also returns true even if ip is in the IPv4
  /// private address space or IPv6 unique local address space.
  /// It returns false for the zero [Addr].
  /// 
  /// For reference, see RFC 1122, RFC 4291, and RFC 4632.
  fn IsGlobalUnicast(self) -> bool

  /// IsInterfaceLocalMulticast reports whether ip is an IPv6 interface-local
  /// multicast address.
  fn IsInterfaceLocalMulticast(self) -> bool

  /// IsLinkLocalMulticast reports whether ip is a link-local multicast address.
  fn IsLinkLocalMulticast(self) -> bool

  /// IsLinkLocalUnicast reports whether ip is a link-local unicast address.
  fn IsLinkLocalUnicast(self) -> bool

  /// IsLoopback reports whether ip is a loopback address.
  fn IsLoopback(self) -> bool

  /// IsMulticast reports whether ip is a multicast address.
  fn IsMulticast(self) -> bool

  /// IsPrivate reports whether ip is a private address, according to RFC 1918
  /// (IPv4 addresses) and RFC 4193 (IPv6 addresses). That is, it reports whether
  /// ip is in 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, or fc00::/7. This is the
  /// same as [net.IP.IsPrivate].
  fn IsPrivate(self) -> bool

  /// IsUnspecified reports whether ip is an unspecified address, either the IPv4
  /// address "0.0.0.0" or the IPv6 address "::".
  /// 
  /// Note that the zero [Addr] is not an unspecified address.
  fn IsUnspecified(self) -> bool

  /// IsValid reports whether the [Addr] is an initialized address (not the zero Addr).
  /// 
  /// Note that "0.0.0.0" and "::" are both valid values.
  fn IsValid(self) -> bool

  /// Less reports whether ip sorts before ip2.
  /// IP addresses sort first by length, then their address.
  /// IPv6 addresses with zones sort just after the same address without a zone.
  fn Less(self, ip2: Addr) -> bool

  /// MarshalBinary implements the [encoding.BinaryMarshaler] interface.
  /// It returns a zero-length slice for the zero [Addr],
  /// the 4-byte form for an IPv4 address,
  /// and the 16-byte form with zone appended for an IPv6 address.
  fn MarshalBinary(self) -> Result<Slice<uint8>, error>

  /// MarshalText implements the [encoding.TextMarshaler] interface,
  /// The encoding is the same as returned by [Addr.String], with one exception:
  /// If ip is the zero [Addr], the encoding is the empty string.
  fn MarshalText(self) -> Result<Slice<uint8>, error>

  /// Next returns the address following ip.
  /// If there is none, it returns the zero [Addr].
  fn Next(self) -> Addr

  /// Prefix keeps only the top b bits of IP, producing a Prefix
  /// of the specified length.
  /// If ip is a zero [Addr], Prefix always returns a zero Prefix and a nil error.
  /// Otherwise, if bits is less than zero or greater than ip.BitLen(),
  /// Prefix returns an error.
  fn Prefix(self, b: int) -> Result<Prefix, error>

  /// Prev returns the IP before ip.
  /// If there is none, it returns the IP zero value.
  fn Prev(self) -> Addr

  /// String returns the string form of the IP address ip.
  /// It returns one of 5 forms:
  /// 
  ///   - "invalid IP", if ip is the zero [Addr]
  ///   - IPv4 dotted decimal ("192.0.2.1")
  ///   - IPv6 ("2001:db8::1")
  ///   - "::ffff:1.2.3.4" (if [Addr.Is4In6])
  ///   - IPv6 with zone ("fe80:db8::1%eth0")
  /// 
  /// Note that unlike package net's IP.String method,
  /// IPv4-mapped IPv6 addresses format with a "::ffff:"
  /// prefix before the dotted quad.
  fn String(self) -> string

  /// StringExpanded is like [Addr.String] but IPv6 addresses are expanded with leading
  /// zeroes and no "::" compression. For example, "2001:db8::1" becomes
  /// "2001:0db8:0000:0000:0000:0000:0000:0001".
  fn StringExpanded(self) -> string

  /// Unmap returns ip with any IPv4-mapped IPv6 address prefix removed.
  /// 
  /// That is, if ip is an IPv6 address wrapping an IPv4 address, it
  /// returns the wrapped IPv4 address. Otherwise it returns ip unmodified.
  fn Unmap(self) -> Addr

  /// UnmarshalBinary implements the [encoding.BinaryUnmarshaler] interface.
  /// It expects data in the form generated by MarshalBinary.
  fn UnmarshalBinary(self: Ref<Addr>, b: Slice<uint8>) -> Result<(), error>

  /// UnmarshalText implements the encoding.TextUnmarshaler interface.
  /// The IP address is expected in a form accepted by [ParseAddr].
  /// 
  /// If text is empty, UnmarshalText sets *ip to the zero [Addr] and
  /// returns no error.
  fn UnmarshalText(self: Ref<Addr>, text: Slice<uint8>) -> Result<(), error>

  /// WithZone returns an IP that's the same as ip but with the provided
  /// zone. If zone is empty, the zone is removed. If ip is an IPv4
  /// address, WithZone is a no-op and returns ip unchanged.
  fn WithZone(self, zone: string) -> Addr

  /// Zone returns ip's IPv6 scoped addressing zone, if any.
  fn Zone(self) -> string
}

impl AddrPort {
  /// Addr returns p's IP address.
  fn Addr(self) -> Addr

  /// AppendBinary implements the [encoding.BinaryAppendler] interface.
  /// It returns [Addr.AppendBinary] with an additional two bytes appended
  /// containing the port in little-endian.
  fn AppendBinary(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// AppendText implements the [encoding.TextAppender] interface. The
  /// encoding is the same as returned by [AddrPort.AppendTo].
  fn AppendText(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// AppendTo appends a text encoding of p,
  /// as generated by [AddrPort.MarshalText],
  /// to b and returns the extended buffer.
  fn AppendTo(self, mut b: Slice<uint8>) -> Slice<uint8>

  /// Compare returns an integer comparing two AddrPorts.
  /// The result will be 0 if p == p2, -1 if p < p2, and +1 if p > p2.
  /// AddrPorts sort first by IP address, then port.
  fn Compare(self, p2: AddrPort) -> int

  /// IsValid reports whether p.Addr() is valid.
  /// All ports are valid, including zero.
  fn IsValid(self) -> bool

  /// MarshalBinary implements the [encoding.BinaryMarshaler] interface.
  /// It returns [Addr.MarshalBinary] with an additional two bytes appended
  /// containing the port in little-endian.
  fn MarshalBinary(self) -> Result<Slice<uint8>, error>

  /// MarshalText implements the [encoding.TextMarshaler] interface. The
  /// encoding is the same as returned by [AddrPort.String], with one exception: if
  /// p.Addr() is the zero [Addr], the encoding is the empty string.
  fn MarshalText(self) -> Result<Slice<uint8>, error>

  /// Port returns p's port.
  fn Port(self) -> uint16

  fn String(self) -> string

  /// UnmarshalBinary implements the [encoding.BinaryUnmarshaler] interface.
  /// It expects data in the form generated by [AddrPort.MarshalBinary].
  fn UnmarshalBinary(self: Ref<AddrPort>, b: Slice<uint8>) -> Result<(), error>

  /// UnmarshalText implements the encoding.TextUnmarshaler
  /// interface. The [AddrPort] is expected in a form
  /// generated by [AddrPort.MarshalText] or accepted by [ParseAddrPort].
  fn UnmarshalText(self: Ref<AddrPort>, text: Slice<uint8>) -> Result<(), error>
}

impl Prefix {
  /// Addr returns p's IP address.
  fn Addr(self) -> Addr

  /// AppendBinary implements the [encoding.AppendMarshaler] interface.
  /// It returns [Addr.AppendBinary] with an additional byte appended
  /// containing the prefix bits.
  fn AppendBinary(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// AppendText implements the [encoding.TextAppender] interface.
  /// It is the same as [Prefix.AppendTo].
  fn AppendText(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// AppendTo appends a text encoding of p,
  /// as generated by [Prefix.MarshalText],
  /// to b and returns the extended buffer.
  fn AppendTo(self, mut b: Slice<uint8>) -> Slice<uint8>

  /// Bits returns p's prefix length.
  /// 
  /// It reports -1 if invalid.
  fn Bits(self) -> int

  /// Contains reports whether the network p includes ip.
  /// 
  /// An IPv4 address will not match an IPv6 prefix.
  /// An IPv4-mapped IPv6 address will not match an IPv4 prefix.
  /// A zero-value IP will not match any prefix.
  /// If ip has an IPv6 zone, Contains returns false,
  /// because Prefixes strip zones.
  fn Contains(self, ip: Addr) -> bool

  /// IsSingleIP reports whether p contains exactly one IP.
  fn IsSingleIP(self) -> bool

  /// IsValid reports whether p.Bits() has a valid range for p.Addr().
  /// If p.Addr() is the zero [Addr], IsValid returns false.
  /// Note that if p is the zero [Prefix], then p.IsValid() == false.
  fn IsValid(self) -> bool

  /// MarshalBinary implements the [encoding.BinaryMarshaler] interface.
  /// It returns [Addr.MarshalBinary] with an additional byte appended
  /// containing the prefix bits.
  fn MarshalBinary(self) -> Result<Slice<uint8>, error>

  /// MarshalText implements the [encoding.TextMarshaler] interface,
  /// The encoding is the same as returned by [Prefix.String], with one exception:
  /// If p is the zero value, the encoding is the empty string.
  fn MarshalText(self) -> Result<Slice<uint8>, error>

  /// Masked returns p in its canonical form, with all but the high
  /// p.Bits() bits of p.Addr() masked off.
  /// 
  /// If p is zero or otherwise invalid, Masked returns the zero [Prefix].
  fn Masked(self) -> Prefix

  /// Overlaps reports whether p and o contain any IP addresses in common.
  /// 
  /// If p and o are of different address families or either have a zero
  /// IP, it reports false. Like the Contains method, a prefix with an
  /// IPv4-mapped IPv6 address is still treated as an IPv6 mask.
  fn Overlaps(self, o: Prefix) -> bool

  /// String returns the CIDR notation of p: "<ip>/<bits>".
  fn String(self) -> string

  /// UnmarshalBinary implements the [encoding.BinaryUnmarshaler] interface.
  /// It expects data in the form generated by [Prefix.MarshalBinary].
  fn UnmarshalBinary(self: Ref<Prefix>, b: Slice<uint8>) -> Result<(), error>

  /// UnmarshalText implements the encoding.TextUnmarshaler interface.
  /// The IP address is expected in a form accepted by [ParsePrefix]
  /// or generated by [Prefix.MarshalText].
  fn UnmarshalText(self: Ref<Prefix>, text: Slice<uint8>) -> Result<(), error>
}
