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

import "go:context"
import "go:io"
import "go:net/netip"
import "go:os"
import "go:syscall"
import "go:time"

pub fn CIDRMask(ones: int, bits: int) -> IPMask

/// Dial connects to the address on the named network.
/// 
/// Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only),
/// "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4"
/// (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and
/// "unixpacket".
/// 
/// For TCP and UDP networks, the address has the form "host:port".
/// The host must be a literal IP address, or a host name that can be
/// resolved to IP addresses.
/// The port must be a literal port number or a service name.
/// If the host is a literal IPv6 address it must be enclosed in square
/// brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80".
/// The zone specifies the scope of the literal IPv6 address as defined
/// in RFC 4007.
/// The functions [JoinHostPort] and [SplitHostPort] manipulate a pair of
/// host and port in this form.
/// When using TCP, and the host resolves to multiple IP addresses,
/// Dial will try each IP address in order until one succeeds.
/// 
/// Examples:
/// 
/// 	Dial("tcp", "golang.org:http")
/// 	Dial("tcp", "192.0.2.1:http")
/// 	Dial("tcp", "198.51.100.1:80")
/// 	Dial("udp", "[2001:db8::1]:domain")
/// 	Dial("udp", "[fe80::1%lo0]:53")
/// 	Dial("tcp", ":80")
/// 
/// For IP networks, the network must be "ip", "ip4" or "ip6" followed
/// by a colon and a literal protocol number or a protocol name, and
/// the address has the form "host". The host must be a literal IP
/// address or a literal IPv6 address with zone.
/// It depends on each operating system how the operating system
/// behaves with a non-well known protocol number such as "0" or "255".
/// 
/// Examples:
/// 
/// 	Dial("ip4:1", "192.0.2.1")
/// 	Dial("ip6:ipv6-icmp", "2001:db8::1")
/// 	Dial("ip6:58", "fe80::1%lo0")
/// 
/// For TCP, UDP and IP networks, if the host is empty or a literal
/// unspecified IP address, as in ":80", "0.0.0.0:80" or "[::]:80" for
/// TCP and UDP, "", "0.0.0.0" or "::" for IP, the local system is
/// assumed.
/// 
/// For Unix networks, the address must be a file system path.
pub fn Dial(network: string, address: string) -> Result<Conn, error>

/// DialIP acts like [Dial] for IP networks.
/// 
/// The network must be an IP network name; see func Dial for details.
/// 
/// If laddr is nil, a local address is automatically chosen.
/// If the IP field of raddr is nil or an unspecified IP address, the
/// local system is assumed.
pub fn DialIP(network: string, laddr: Ref<IPAddr>, raddr: Ref<IPAddr>) -> Result<Ref<IPConn>, error>

/// DialTCP acts like [Dial] for TCP networks.
/// 
/// The network must be a TCP network name; see func Dial for details.
/// 
/// If laddr is nil, a local address is automatically chosen.
/// If the IP field of raddr is nil or an unspecified IP address, the
/// local system is assumed.
pub fn DialTCP(network: string, laddr: Ref<TCPAddr>, raddr: Ref<TCPAddr>) -> Result<Ref<TCPConn>, error>

/// DialTimeout acts like [Dial] but takes a timeout.
/// 
/// The timeout includes name resolution, if required.
/// When using TCP, and the host in the address parameter resolves to
/// multiple IP addresses, the timeout is spread over each consecutive
/// dial, such that each is given an appropriate fraction of the time
/// to connect.
/// 
/// See func Dial for a description of the network and address
/// parameters.
pub fn DialTimeout(network: string, address: string, timeout: time.Duration) -> Result<Conn, error>

/// DialUDP acts like [Dial] for UDP networks.
/// 
/// The network must be a UDP network name; see func [Dial] for details.
/// 
/// If laddr is nil, a local address is automatically chosen.
/// If the IP field of raddr is nil or an unspecified IP address, the
/// local system is assumed.
pub fn DialUDP(network: string, laddr: Ref<UDPAddr>, raddr: Ref<UDPAddr>) -> Result<Ref<UDPConn>, error>

/// DialUnix acts like [Dial] for Unix networks.
/// 
/// The network must be a Unix network name; see func [Dial] for details.
/// 
/// If laddr is non-nil, it is used as the local address for the
/// connection.
pub fn DialUnix(network: string, laddr: Ref<UnixAddr>, raddr: Ref<UnixAddr>) -> Result<Ref<UnixConn>, error>

/// FileConn returns a copy of the network connection corresponding to
/// the open file f.
/// It is the caller's responsibility to close f when finished.
/// Closing c does not affect f, and closing f does not affect c.
pub fn FileConn(f: Ref<os.File>) -> Result<Conn, error>

/// FileListener returns a copy of the network listener corresponding
/// to the open file f.
/// It is the caller's responsibility to close ln when finished.
/// Closing ln does not affect f, and closing f does not affect ln.
pub fn FileListener(f: Ref<os.File>) -> Result<Listener, error>

/// FilePacketConn returns a copy of the packet network connection
/// corresponding to the open file f.
/// It is the caller's responsibility to close f when finished.
/// Closing c does not affect f, and closing f does not affect c.
pub fn FilePacketConn(f: Ref<os.File>) -> Result<PacketConn, error>

pub fn IPv4(a: uint8, b: uint8, c: uint8, d: uint8) -> IP

pub fn IPv4Mask(a: uint8, b: uint8, c: uint8, d: uint8) -> IPMask

/// InterfaceAddrs returns a list of the system's unicast interface
/// addresses.
/// 
/// The returned list does not identify the associated interface; use
/// Interfaces and [Interface.Addrs] for more detail.
pub fn InterfaceAddrs() -> Result<Slice<Addr>, error>

/// InterfaceByIndex returns the interface specified by index.
/// 
/// On Solaris, it returns one of the logical network interfaces
/// sharing the logical data link; for more precision use
/// [InterfaceByName].
pub fn InterfaceByIndex(index: int) -> Result<Ref<Interface>, error>

/// InterfaceByName returns the interface specified by name.
pub fn InterfaceByName(name: string) -> Result<Ref<Interface>, error>

/// Interfaces returns a list of the system's network interfaces.
pub fn Interfaces() -> Result<Slice<Interface>, error>

/// JoinHostPort combines host and port into a network address of the
/// form "host:port". If host contains a colon, as found in literal
/// IPv6 addresses, then JoinHostPort returns "[host]:port".
/// 
/// See func Dial for a description of the host and port parameters.
pub fn JoinHostPort(host: string, port: string) -> string

/// Listen announces on the local network address.
/// 
/// The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
/// 
/// For TCP networks, if the host in the address parameter is empty or
/// a literal unspecified IP address, Listen listens on all available
/// unicast and anycast IP addresses of the local system.
/// To only use IPv4, use network "tcp4".
/// The address can use a host name, but this is not recommended,
/// because it will create a listener for at most one of the host's IP
/// addresses.
/// If the port in the address parameter is empty or "0", as in
/// "127.0.0.1:" or "[::1]:0", a port number is automatically chosen.
/// The [Addr] method of [Listener] can be used to discover the chosen
/// port.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
/// 
/// Listen uses context.Background internally; to specify the context, use
/// [ListenConfig.Listen].
pub fn Listen(network: string, address: string) -> Result<Listener, error>

/// ListenIP acts like [ListenPacket] for IP networks.
/// 
/// The network must be an IP network name; see func Dial for details.
/// 
/// If the IP field of laddr is nil or an unspecified IP address,
/// ListenIP listens on all available IP addresses of the local system
/// except multicast IP addresses.
pub fn ListenIP(network: string, laddr: Ref<IPAddr>) -> Result<Ref<IPConn>, error>

/// ListenMulticastUDP acts like [ListenPacket] for UDP networks but
/// takes a group address on a specific network interface.
/// 
/// The network must be a UDP network name; see func [Dial] for details.
/// 
/// ListenMulticastUDP listens on all available IP addresses of the
/// local system including the group, multicast IP address.
/// If ifi is nil, ListenMulticastUDP uses the system-assigned
/// multicast interface, although this is not recommended because the
/// assignment depends on platforms and sometimes it might require
/// routing configuration.
/// If the Port field of gaddr is 0, a port number is automatically
/// chosen.
/// 
/// ListenMulticastUDP is just for convenience of simple, small
/// applications. There are [golang.org/x/net/ipv4] and
/// [golang.org/x/net/ipv6] packages for general purpose uses.
/// 
/// Note that ListenMulticastUDP will set the IP_MULTICAST_LOOP socket option
/// to 0 under IPPROTO_IP, to disable loopback of multicast packets.
pub fn ListenMulticastUDP(
  network: string,
  ifi: Ref<Interface>,
  gaddr: Ref<UDPAddr>,
) -> Result<Ref<UDPConn>, error>

/// ListenPacket announces on the local network address.
/// 
/// The network must be "udp", "udp4", "udp6", "unixgram", or an IP
/// transport. The IP transports are "ip", "ip4", or "ip6" followed by
/// a colon and a literal protocol number or a protocol name, as in
/// "ip:1" or "ip:icmp".
/// 
/// For UDP and IP networks, if the host in the address parameter is
/// empty or a literal unspecified IP address, ListenPacket listens on
/// all available IP addresses of the local system except multicast IP
/// addresses.
/// To only use IPv4, use network "udp4" or "ip4:proto".
/// The address can use a host name, but this is not recommended,
/// because it will create a listener for at most one of the host's IP
/// addresses.
/// If the port in the address parameter is empty or "0", as in
/// "127.0.0.1:" or "[::1]:0", a port number is automatically chosen.
/// The LocalAddr method of [PacketConn] can be used to discover the
/// chosen port.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
/// 
/// ListenPacket uses context.Background internally; to specify the context, use
/// [ListenConfig.ListenPacket].
pub fn ListenPacket(network: string, address: string) -> Result<PacketConn, error>

/// ListenTCP acts like [Listen] for TCP networks.
/// 
/// The network must be a TCP network name; see func Dial for details.
/// 
/// If the IP field of laddr is nil or an unspecified IP address,
/// ListenTCP listens on all available unicast and anycast IP addresses
/// of the local system.
/// If the Port field of laddr is 0, a port number is automatically
/// chosen.
pub fn ListenTCP(network: string, laddr: Ref<TCPAddr>) -> Result<Ref<TCPListener>, error>

/// ListenUDP acts like [ListenPacket] for UDP networks.
/// 
/// The network must be a UDP network name; see func [Dial] for details.
/// 
/// If the IP field of laddr is nil or an unspecified IP address,
/// ListenUDP listens on all available IP addresses of the local system
/// except multicast IP addresses.
/// If the Port field of laddr is 0, a port number is automatically
/// chosen.
pub fn ListenUDP(network: string, laddr: Ref<UDPAddr>) -> Result<Ref<UDPConn>, error>

/// ListenUnix acts like [Listen] for Unix networks.
/// 
/// The network must be "unix" or "unixpacket".
pub fn ListenUnix(network: string, laddr: Ref<UnixAddr>) -> Result<Ref<UnixListener>, error>

/// ListenUnixgram acts like [ListenPacket] for Unix networks.
/// 
/// The network must be "unixgram".
pub fn ListenUnixgram(network: string, laddr: Ref<UnixAddr>) -> Result<Ref<UnixConn>, error>

/// LookupAddr performs a reverse lookup for the given address, returning a list
/// of names mapping to that address.
/// 
/// The returned names are validated to be properly formatted presentation-format
/// domain names. If the response contains invalid names, those records are filtered
/// out and an error will be returned alongside the remaining results, if any.
/// 
/// When using the host C library resolver, at most one result will be
/// returned. To bypass the host resolver, use a custom [Resolver].
/// 
/// LookupAddr uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupAddr].
pub fn LookupAddr(addr: string) -> Result<Slice<string>, error>

/// LookupCNAME returns the canonical name for the given host.
/// Callers that do not care about the canonical name can call
/// [LookupHost] or [LookupIP] directly; both take care of resolving
/// the canonical name as part of the lookup.
/// 
/// A canonical name is the final name after following zero
/// or more CNAME records.
/// LookupCNAME does not return an error if host does not
/// contain DNS "CNAME" records, as long as host resolves to
/// address records.
/// 
/// The returned canonical name is validated to be a properly
/// formatted presentation-format domain name.
/// 
/// LookupCNAME uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupCNAME].
pub fn LookupCNAME(host: string) -> Result<string, error>

/// LookupHost looks up the given host using the local resolver.
/// It returns a slice of that host's addresses.
/// 
/// LookupHost uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupHost].
pub fn LookupHost(host: string) -> Result<Slice<string>, error>

/// LookupIP looks up host using the local resolver.
/// It returns a slice of that host's IPv4 and IPv6 addresses.
pub fn LookupIP(host: string) -> Result<Slice<IP>, error>

/// LookupMX returns the DNS MX records for the given domain name sorted by preference.
/// 
/// The returned mail server names are validated to be properly
/// formatted presentation-format domain names, or numeric IP addresses.
/// If the response contains invalid names, those records are filtered out
/// and an error will be returned alongside the remaining results, if any.
/// 
/// LookupMX uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupMX].
pub fn LookupMX(name: string) -> Result<Slice<Ref<MX>>, error>

/// LookupNS returns the DNS NS records for the given domain name.
/// 
/// The returned name server names are validated to be properly
/// formatted presentation-format domain names. If the response contains
/// invalid names, those records are filtered out and an error
/// will be returned alongside the remaining results, if any.
/// 
/// LookupNS uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupNS].
pub fn LookupNS(name: string) -> Result<Slice<Ref<NS>>, error>

/// LookupPort looks up the port for the given network and service.
/// 
/// LookupPort uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupPort].
pub fn LookupPort(network: string, service: string) -> Result<int, error>

/// LookupSRV tries to resolve an [SRV] query of the given service,
/// protocol, and domain name. The proto is "tcp" or "udp".
/// The returned records are sorted by priority and randomized
/// by weight within a priority.
/// 
/// LookupSRV constructs the DNS name to look up following RFC 2782.
/// That is, it looks up _service._proto.name. To accommodate services
/// publishing SRV records under non-standard names, if both service
/// and proto are empty strings, LookupSRV looks up name directly.
/// 
/// The returned service names are validated to be properly
/// formatted presentation-format domain names. If the response contains
/// invalid names, those records are filtered out and an error
/// will be returned alongside the remaining results, if any.
pub fn LookupSRV(service: string, proto: string, name: string) -> Result<(string, Slice<Ref<SRV>>), error>

/// LookupTXT returns the DNS TXT records for the given domain name.
/// 
/// If a DNS TXT record holds multiple strings, they are concatenated as a
/// single string.
/// 
/// LookupTXT uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupTXT].
pub fn LookupTXT(name: string) -> Result<Slice<string>, error>

/// ParseCIDR parses s as a CIDR notation IP address and prefix length,
/// like "192.0.2.0/24" or "2001:db8::/32", as defined in
/// RFC 4632 and RFC 4291.
/// 
/// It returns the IP address and the network implied by the IP and
/// prefix length.
/// For example, ParseCIDR("192.0.2.1/24") returns the IP address
/// 192.0.2.1 and the network 192.0.2.0/24.
pub fn ParseCIDR(s: string) -> Result<(IP, Ref<IPNet>), error>

pub fn ParseIP(s: string) -> IP

/// ParseMAC parses s as an IEEE 802 MAC-48, EUI-48, EUI-64, or a 20-octet
/// IP over InfiniBand link-layer address using one of the following formats:
/// 
/// 	00:00:5e:00:53:01
/// 	02:00:5e:10:00:00:00:01
/// 	00:00:00:00:fe:80:00:00:00:00:00:00:02:00:5e:10:00:00:00:01
/// 	00-00-5e-00-53-01
/// 	02-00-5e-10-00-00-00-01
/// 	00-00-00-00-fe-80-00-00-00-00-00-00-02-00-5e-10-00-00-00-01
/// 	0000.5e00.5301
/// 	0200.5e10.0000.0001
/// 	0000.0000.fe80.0000.0000.0000.0200.5e10.0000.0001
pub fn ParseMAC(s: string) -> Result<HardwareAddr, error>

/// Pipe creates a synchronous, in-memory, full duplex
/// network connection; both ends implement the [Conn] interface.
/// Reads on one end are matched with writes on the other,
/// copying data directly between the two; there is no internal
/// buffering.
pub fn Pipe() -> (Conn, Conn)

/// ResolveIPAddr returns an address of IP end point.
/// 
/// The network must be an IP network name.
/// 
/// If the host in the address parameter is not a literal IP address,
/// ResolveIPAddr resolves the address to an address of IP end point.
/// Otherwise, it parses the address as a literal IP address.
/// The address parameter can use a host name, but this is not
/// recommended, because it will return at most one of the host name's
/// IP addresses.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveIPAddr(network: string, address: string) -> Result<Ref<IPAddr>, error>

/// ResolveTCPAddr returns an address of TCP end point.
/// 
/// The network must be a TCP network name.
/// 
/// If the host in the address parameter is not a literal IP address or
/// the port is not a literal port number, ResolveTCPAddr resolves the
/// address to an address of TCP end point.
/// Otherwise, it parses the address as a pair of literal IP address
/// and port number.
/// The address parameter can use a host name, but this is not
/// recommended, because it will return at most one of the host name's
/// IP addresses.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveTCPAddr(network: string, address: string) -> Result<Ref<TCPAddr>, error>

/// ResolveUDPAddr returns an address of UDP end point.
/// 
/// The network must be a UDP network name.
/// 
/// If the host in the address parameter is not a literal IP address or
/// the port is not a literal port number, ResolveUDPAddr resolves the
/// address to an address of UDP end point.
/// Otherwise, it parses the address as a pair of literal IP address
/// and port number.
/// The address parameter can use a host name, but this is not
/// recommended, because it will return at most one of the host name's
/// IP addresses.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveUDPAddr(network: string, address: string) -> Result<Ref<UDPAddr>, error>

/// ResolveUnixAddr returns an address of Unix domain socket end point.
/// 
/// The network must be a Unix network name.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveUnixAddr(network: string, address: string) -> Result<Ref<UnixAddr>, error>

/// SplitHostPort splits a network address of the form "host:port",
/// "host%zone:port", "[host]:port" or "[host%zone]:port" into host or
/// host%zone and port.
/// 
/// A literal IPv6 address in hostport must be enclosed in square
/// brackets, as in "[::1]:80", "[::1%lo0]:80".
/// 
/// See func Dial for a description of the hostport parameter, and host
/// and port results.
pub fn SplitHostPort(hostport: string) -> Result<(string, string), error>

pub fn TCPAddrFromAddrPort(addr: netip.AddrPort) -> Ref<TCPAddr>

pub fn UDPAddrFromAddrPort(addr: netip.AddrPort) -> Ref<UDPAddr>

/// Addr represents a network end point address.
/// 
/// The two methods [Addr.Network] and [Addr.String] conventionally return strings
/// that can be passed as the arguments to [Dial], but the exact form
/// and meaning of the strings is up to the implementation.
pub interface Addr {
  fn Network() -> string
  fn String() -> string
}

pub struct AddrError {
  pub Err: string,
  pub Addr: string,
}

/// Buffers contains zero or more runs of bytes to write.
/// 
/// On certain machines, for certain types of connections, this is
/// optimized into an OS-specific batch write operation (such as
/// "writev").
pub struct Buffers(Slice<Slice<uint8>>)

/// Conn is a generic stream-oriented network connection.
/// 
/// Multiple goroutines may invoke methods on a Conn simultaneously.
pub interface Conn {
  fn Close() -> Result<(), error>
  fn LocalAddr() -> Addr
  fn Read(mut b: Slice<uint8>) -> Partial<int, error>
  fn RemoteAddr() -> Addr
  fn SetDeadline(t: time.Time) -> Result<(), error>
  fn SetReadDeadline(t: time.Time) -> Result<(), error>
  fn SetWriteDeadline(t: time.Time) -> Result<(), error>
  fn Write(b: Slice<uint8>) -> Partial<int, error>
}

/// DNSConfigError represents an error reading the machine's DNS configuration.
/// (No longer used; kept for compatibility.)
pub struct DNSConfigError {
  pub Err: error,
}

/// DNSError represents a DNS lookup error.
pub struct DNSError {
  pub UnwrapErr: error,
  pub Err: string,
  pub Name: string,
  pub Server: string,
  pub IsTimeout: bool,
  pub IsTemporary: bool,
  pub IsNotFound: bool,
}

/// A Dialer contains options for connecting to an address.
/// 
/// The zero value for each field is equivalent to dialing
/// without that option. Dialing with the zero value of Dialer
/// is therefore equivalent to just calling the [Dial] function.
/// 
/// It is safe to call Dialer's methods concurrently.
pub struct Dialer {
  pub Timeout: time.Duration,
  pub Deadline: time.Time,
  pub LocalAddr: Option<Addr>,
  pub DualStack: bool,
  pub FallbackDelay: time.Duration,
  pub KeepAlive: time.Duration,
  pub KeepAliveConfig: KeepAliveConfig,
  pub Resolver: Option<Ref<Resolver>>,
  pub Cancel: Receiver<()>,
  pub Control: Option<fn(string, string, syscall.RawConn) -> Result<(), error>>,
  pub ControlContext: Option<fn(context.Context, string, string, syscall.RawConn) -> Result<(), error>>,
}

/// An Error represents a network error.
pub interface Error {
  fn Error() -> string
  fn Temporary() -> bool
  fn Timeout() -> bool
}

pub struct Flags(uint)

/// A HardwareAddr represents a physical hardware address.
pub struct HardwareAddr(Slice<uint8>)

/// An IP is a single IP address, a slice of bytes.
/// Functions in this package accept either 4-byte (IPv4)
/// or 16-byte (IPv6) slices as input.
/// 
/// Note that in this documentation, referring to an
/// IP address as an IPv4 address or an IPv6 address
/// is a semantic property of the address, not just the
/// length of the byte slice: a 16-byte slice can still
/// be an IPv4 address.
pub struct IP(Slice<uint8>)

/// IPAddr represents the address of an IP end point.
pub struct IPAddr {
  pub IP: IP,
  pub Zone: string,
}

/// IPConn is the implementation of the [Conn] and [PacketConn] interfaces
/// for IP network connections.
pub type IPConn

/// An IPMask is a bitmask that can be used to manipulate
/// IP addresses for IP addressing and routing.
/// 
/// See type [IPNet] and func [ParseCIDR] for details.
pub struct IPMask(Slice<uint8>)

/// An IPNet represents an IP network.
pub struct IPNet {
  pub IP: IP,
  pub Mask: IPMask,
}

/// Interface represents a mapping between network interface name
/// and index. It also represents network interface facility
/// information.
pub struct Interface {
  pub Index: int,
  pub MTU: int,
  pub Name: string,
  pub HardwareAddr: HardwareAddr,
  pub Flags: Flags,
}

pub struct InvalidAddrError(string)

/// KeepAliveConfig contains TCP keep-alive options.
/// 
/// If the Idle, Interval, or Count fields are zero, a default value is chosen.
/// If a field is negative, the corresponding socket-level option will be left unchanged.
/// 
/// Note that prior to Windows 10 version 1709, neither setting Idle and Interval
/// separately nor changing Count (which is usually 10) is supported.
/// Therefore, it's recommended to set both Idle and Interval to non-negative values
/// in conjunction with a -1 for Count on those old Windows if you intend to customize
/// the TCP keep-alive settings.
/// By contrast, if only one of Idle and Interval is set to a non-negative value,
/// the other will be set to the system default value, and ultimately,
/// set both Idle and Interval to negative values if you want to leave them unchanged.
/// 
/// Note that Solaris and its derivatives do not support setting Interval to a non-negative value
/// and Count to a negative value, or vice-versa.
pub struct KeepAliveConfig {
  pub Enable: bool,
  pub Idle: time.Duration,
  pub Interval: time.Duration,
  pub Count: int,
}

/// ListenConfig contains options for listening to an address.
pub struct ListenConfig {
  pub Control: Option<fn(string, string, syscall.RawConn) -> Result<(), error>>,
  pub KeepAlive: time.Duration,
  pub KeepAliveConfig: KeepAliveConfig,
}

/// A Listener is a generic network listener for stream-oriented protocols.
/// 
/// Multiple goroutines may invoke methods on a Listener simultaneously.
pub interface Listener {
  fn Accept() -> Result<Conn, error>
  fn Addr() -> Addr
  fn Close() -> Result<(), error>
}

/// An MX represents a single DNS MX record.
pub struct MX {
  pub Host: string,
  pub Pref: uint16,
}

/// An NS represents a single DNS NS record.
pub struct NS {
  pub Host: string,
}

/// OpError is the error type usually returned by functions in the net
/// package. It describes the operation, network type, and address of
/// an error.
pub struct OpError {
  pub Op: string,
  pub Net: string,
  pub Source: Option<Addr>,
  pub Addr: Option<Addr>,
  pub Err: error,
}

/// PacketConn is a generic packet-oriented network connection.
/// 
/// Multiple goroutines may invoke methods on a PacketConn simultaneously.
pub interface PacketConn {
  fn Close() -> Result<(), error>
  fn LocalAddr() -> Addr
  fn ReadFrom(mut p: Slice<uint8>) -> Result<(int, Addr), error>
  fn SetDeadline(t: time.Time) -> Result<(), error>
  fn SetReadDeadline(t: time.Time) -> Result<(), error>
  fn SetWriteDeadline(t: time.Time) -> Result<(), error>
  fn WriteTo(p: Slice<uint8>, addr: Addr) -> Result<int, error>
}

/// A ParseError is the error type of literal network address parsers.
pub struct ParseError {
  pub Type: string,
  pub Text: string,
}

/// A Resolver looks up names and numbers.
/// 
/// A nil *Resolver is equivalent to a zero Resolver.
pub struct Resolver {
  pub PreferGo: bool,
  pub StrictErrors: bool,
  pub Dial: Option<fn(context.Context, string, string) -> Result<Conn, error>>,
}

/// An SRV represents a single DNS SRV record.
pub struct SRV {
  pub Target: string,
  pub Port: uint16,
  pub Priority: uint16,
  pub Weight: uint16,
}

/// TCPAddr represents the address of a TCP end point.
pub struct TCPAddr {
  pub IP: IP,
  pub Port: int,
  pub Zone: string,
}

/// TCPConn is an implementation of the [Conn] interface for TCP network
/// connections.
pub type TCPConn

/// TCPListener is a TCP network listener. Clients should typically
/// use variables of type [Listener] instead of assuming TCP.
pub type TCPListener

/// UDPAddr represents the address of a UDP end point.
pub struct UDPAddr {
  pub IP: IP,
  pub Port: int,
  pub Zone: string,
}

/// UDPConn is the implementation of the [Conn] and [PacketConn] interfaces
/// for UDP network connections.
pub type UDPConn

/// UnixAddr represents the address of a Unix domain socket end point.
pub struct UnixAddr {
  pub Name: string,
  pub Net: string,
}

/// UnixConn is an implementation of the [Conn] interface for connections
/// to Unix domain sockets.
pub type UnixConn

/// UnixListener is a Unix domain socket listener. Clients should
/// typically use variables of type [Listener] instead of assuming Unix
/// domain sockets.
pub type UnixListener

pub struct UnknownNetworkError(string)

pub const FlagBroadcast: Flags = 2

pub const FlagLoopback: Flags = 4

pub const FlagMulticast: Flags = 16

pub const FlagPointToPoint: Flags = 8

pub const FlagRunning: Flags = 32

pub const FlagUp: Flags = 1

/// IP address lengths (bytes).
pub const IPv4len = 4

/// IP address lengths (bytes).
pub const IPv6len = 16

/// DefaultResolver is the resolver used by the package-level Lookup
/// functions and by Dialers without a specified Resolver.
pub var DefaultResolver: Ref<Resolver>

/// ErrClosed is the error returned by an I/O call on a network
/// connection that has already been closed, or that is closed by
/// another goroutine before the I/O is completed. This may be wrapped
/// in another error, and should normally be tested using
/// errors.Is(err, net.ErrClosed).
pub var ErrClosed: error

/// Various errors contained in OpError.
pub var ErrWriteToConnected: error

/// Well-known IPv4 addresses
pub var IPv4allrouter: IP

/// Well-known IPv4 addresses
pub var IPv4allsys: IP

/// Well-known IPv4 addresses
pub var IPv4bcast: IP

/// Well-known IPv4 addresses
pub var IPv4zero: IP

/// Well-known IPv6 addresses
pub var IPv6interfacelocalallnodes: IP

/// Well-known IPv6 addresses
pub var IPv6linklocalallnodes: IP

/// Well-known IPv6 addresses
pub var IPv6linklocalallrouters: IP

/// Well-known IPv6 addresses
pub var IPv6loopback: IP

/// Well-known IPv6 addresses
pub var IPv6unspecified: IP

/// Well-known IPv6 addresses
pub var IPv6zero: IP

impl AddrError {
  fn Error(self: Ref<AddrError>) -> string

  fn Temporary(self: Ref<AddrError>) -> bool

  fn Timeout(self: Ref<AddrError>) -> bool
}

impl Buffers {
  /// Read from the buffers.
  /// 
  /// Read implements [io.Reader] for [Buffers].
  /// 
  /// Read modifies the slice v as well as v[i] for 0 <= i < len(v),
  /// but does not modify v[i][j] for any i, j.
  fn Read(self: Ref<Buffers>, mut p: Slice<uint8>) -> Partial<int, error>

  /// WriteTo writes contents of the buffers to w.
  /// 
  /// WriteTo implements [io.WriterTo] for [Buffers].
  /// 
  /// WriteTo modifies the slice v as well as v[i] for 0 <= i < len(v),
  /// but does not modify v[i][j] for any i, j.
  fn WriteTo(self: Ref<Buffers>, w: io.Writer) -> Result<int64, error>
}

impl DNSConfigError {
  fn Error(self: Ref<DNSConfigError>) -> string

  fn Temporary(self: Ref<DNSConfigError>) -> bool

  fn Timeout(self: Ref<DNSConfigError>) -> bool

  fn Unwrap(self: Ref<DNSConfigError>) -> Option<error>
}

impl DNSError {
  fn Error(self: Ref<DNSError>) -> string

  /// Temporary reports whether the DNS error is known to be temporary.
  /// This is not always known; a DNS lookup may fail due to a temporary
  /// error and return a [DNSError] for which Temporary returns false.
  fn Temporary(self: Ref<DNSError>) -> bool

  /// Timeout reports whether the DNS lookup is known to have timed out.
  /// This is not always known; a DNS lookup may fail due to a timeout
  /// and return a [DNSError] for which Timeout returns false.
  fn Timeout(self: Ref<DNSError>) -> bool

  /// Unwrap returns e.UnwrapErr.
  fn Unwrap(self: Ref<DNSError>) -> Option<error>
}

impl Dialer {
  /// Dial connects to the address on the named network.
  /// 
  /// See func Dial for a description of the network and address
  /// parameters.
  /// 
  /// Dial uses [context.Background] internally; to specify the context, use
  /// [Dialer.DialContext].
  fn Dial(self: Ref<Dialer>, network: string, address: string) -> Result<Conn, error>

  /// DialContext connects to the address on the named network using
  /// the provided context.
  /// 
  /// The provided Context must be non-nil. If the context expires before
  /// the connection is complete, an error is returned. Once successfully
  /// connected, any expiration of the context will not affect the
  /// connection.
  /// 
  /// When using TCP, and the host in the address parameter resolves to multiple
  /// network addresses, any dial timeout (from d.Timeout or ctx) is spread
  /// over each consecutive dial, such that each is given an appropriate
  /// fraction of the time to connect.
  /// For example, if a host has 4 IP addresses and the timeout is 1 minute,
  /// the connect to each single address will be given 15 seconds to complete
  /// before trying the next one.
  /// 
  /// See func [Dial] for a description of the network and address
  /// parameters.
  fn DialContext(
    self: Ref<Dialer>,
    ctx: context.Context,
    network: string,
    address: string,
  ) -> Result<Conn, error>

  /// MultipathTCP reports whether MPTCP will be used.
  /// 
  /// This method doesn't check if MPTCP is supported by the operating
  /// system or not.
  fn MultipathTCP(self: Ref<Dialer>) -> bool

  /// SetMultipathTCP directs the [Dial] methods to use, or not use, MPTCP,
  /// if supported by the operating system. This method overrides the
  /// system default and the GODEBUG=multipathtcp=... setting if any.
  /// 
  /// If MPTCP is not available on the host or not supported by the server,
  /// the Dial methods will fall back to TCP.
  fn SetMultipathTCP(self: Ref<Dialer>, use: bool)
}

impl Flags {
  fn String(self) -> string
}

impl HardwareAddr {
  fn String(self) -> string
}

impl IP {
  /// AppendText implements the [encoding.TextAppender] interface.
  /// The encoding is the same as returned by [IP.String], with one exception:
  /// When len(ip) is zero, it appends nothing.
  fn AppendText(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// DefaultMask returns the default IP mask for the IP address ip.
  /// Only IPv4 addresses have default masks; DefaultMask returns
  /// nil if ip is not a valid IPv4 address.
  fn DefaultMask(self) -> IPMask

  /// Equal reports whether ip and x are the same IP address.
  /// An IPv4 address and that same address in IPv6 form are
  /// considered to be equal.
  fn Equal(self, x: IP) -> bool

  /// IsGlobalUnicast reports whether ip is a global unicast
  /// address.
  /// 
  /// The identification of global unicast addresses uses address type
  /// identification as defined in RFC 1122, RFC 4632 and RFC 4291 with
  /// the exception of IPv4 directed broadcast addresses.
  /// It returns true even if ip is in IPv4 private address space or
  /// local IPv6 unicast address space.
  fn IsGlobalUnicast(self) -> bool

  /// IsInterfaceLocalMulticast reports whether ip is
  /// an 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).
  fn IsPrivate(self) -> bool

  /// IsUnspecified reports whether ip is an unspecified address, either
  /// the IPv4 address "0.0.0.0" or the IPv6 address "::".
  fn IsUnspecified(self) -> bool

  /// MarshalText implements the [encoding.TextMarshaler] interface.
  /// The encoding is the same as returned by [IP.String], with one exception:
  /// When len(ip) is zero, it returns an empty slice.
  fn MarshalText(self) -> Result<Slice<uint8>, error>

  /// Mask returns the result of masking the IP address ip with mask.
  fn Mask(self, mask: IPMask) -> IP

  /// String returns the string form of the IP address ip.
  /// It returns one of 4 forms:
  ///   - "<nil>", if ip has length 0
  ///   - dotted decimal ("192.0.2.1"), if ip is an IPv4 or IP4-mapped IPv6 address
  ///   - IPv6 conforming to RFC 5952 ("2001:db8::1"), if ip is a valid IPv6 address
  ///   - the hexadecimal form of ip, without punctuation, if no other cases apply
  fn String(self) -> string

  /// To16 converts the IP address ip to a 16-byte representation.
  /// If ip is not an IP address (it is the wrong length), To16 returns nil.
  fn To16(self) -> IP

  /// To4 converts the IPv4 address ip to a 4-byte representation.
  /// If ip is not an IPv4 address, To4 returns nil.
  fn To4(self) -> IP

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

impl IPAddr {
  /// Network returns the address's network name, "ip".
  fn Network(self: Ref<IPAddr>) -> string

  fn String(self: Ref<IPAddr>) -> string
}

impl IPConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<IPConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<IPConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<IPConn>) -> Addr

  /// Read implements the Conn Read method.
  fn Read(self: Ref<IPConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [PacketConn] ReadFrom method.
  fn ReadFrom(self: Ref<IPConn>, mut b: Slice<uint8>) -> Result<(int, Addr), error>

  /// ReadFromIP acts like ReadFrom but returns an IPAddr.
  fn ReadFromIP(self: Ref<IPConn>, mut b: Slice<uint8>) -> Result<(int, Ref<IPAddr>), error>

  /// ReadMsgIP reads a message from c, copying the payload into b and
  /// the associated out-of-band data into oob. It returns the number of
  /// bytes copied into b, the number of bytes copied into oob, the flags
  /// that were set on the message and the source address of the message.
  /// 
  /// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
  /// used to manipulate IP-level socket options in oob.
  fn ReadMsgIP(self: Ref<IPConn>, mut b: Slice<uint8>, mut oob: Slice<uint8>) -> Result<(int, int, int, Ref<IPAddr>), error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<IPConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<IPConn>, t: time.Time) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<IPConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<IPConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<IPConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<IPConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<IPConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<IPConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteMsgIP writes a message to addr via c, copying the payload from
  /// b and the associated out-of-band data from oob. It returns the
  /// number of payload and out-of-band bytes written.
  /// 
  /// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
  /// used to manipulate IP-level socket options in oob.
  fn WriteMsgIP(
    self: Ref<IPConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: Ref<IPAddr>,
  ) -> Result<(int, int), error>

  /// WriteTo implements the [PacketConn] WriteTo method.
  fn WriteTo(self: Ref<IPConn>, b: Slice<uint8>, addr: Addr) -> Result<int, error>

  /// WriteToIP acts like [IPConn.WriteTo] but takes an [IPAddr].
  fn WriteToIP(self: Ref<IPConn>, b: Slice<uint8>, addr: Ref<IPAddr>) -> Result<int, error>
}

impl IPMask {
  /// Size returns the number of leading ones and total bits in the mask.
  /// If the mask is not in the canonical form--ones followed by zeros--then
  /// Size returns 0, 0.
  fn Size(self) -> (int, int)

  /// String returns the hexadecimal form of m, with no punctuation.
  fn String(self) -> string
}

impl IPNet {
  /// Contains reports whether the network includes ip.
  fn Contains(self: Ref<IPNet>, ip: IP) -> bool

  /// Network returns the address's network name, "ip+net".
  fn Network(self: Ref<IPNet>) -> string

  /// String returns the CIDR notation of n like "192.0.2.0/24"
  /// or "2001:db8::/48" as defined in RFC 4632 and RFC 4291.
  /// If the mask is not in the canonical form, it returns the
  /// string which consists of an IP address, followed by a slash
  /// character and a mask expressed as hexadecimal form with no
  /// punctuation like "198.51.100.0/c000ff00".
  fn String(self: Ref<IPNet>) -> string
}

impl Interface {
  /// Addrs returns a list of unicast interface addresses for a specific
  /// interface.
  fn Addrs(self: Ref<Interface>) -> Result<Slice<Addr>, error>

  /// MulticastAddrs returns a list of multicast, joined group addresses
  /// for a specific interface.
  fn MulticastAddrs(self: Ref<Interface>) -> Result<Slice<Addr>, error>
}

impl InvalidAddrError {
  fn Error(self) -> string

  fn Temporary(self) -> bool

  fn Timeout(self) -> bool
}

impl ListenConfig {
  /// Listen announces on the local network address.
  /// 
  /// See func Listen for a description of the network and address
  /// parameters.
  /// 
  /// The ctx argument is used while resolving the address on which to listen;
  /// it does not affect the returned Listener.
  fn Listen(
    self: Ref<ListenConfig>,
    ctx: context.Context,
    network: string,
    address: string,
  ) -> Result<Listener, error>

  /// ListenPacket announces on the local network address.
  /// 
  /// See func ListenPacket for a description of the network and address
  /// parameters.
  /// 
  /// The ctx argument is used while resolving the address on which to listen;
  /// it does not affect the returned PacketConn.
  fn ListenPacket(
    self: Ref<ListenConfig>,
    ctx: context.Context,
    network: string,
    address: string,
  ) -> Result<PacketConn, error>

  /// MultipathTCP reports whether MPTCP will be used.
  /// 
  /// This method doesn't check if MPTCP is supported by the operating
  /// system or not.
  fn MultipathTCP(self: Ref<ListenConfig>) -> bool

  /// SetMultipathTCP directs the [Listen] method to use, or not use, MPTCP,
  /// if supported by the operating system. This method overrides the
  /// system default and the GODEBUG=multipathtcp=... setting if any.
  /// 
  /// If MPTCP is not available on the host or not supported by the client,
  /// the Listen method will fall back to TCP.
  fn SetMultipathTCP(self: Ref<ListenConfig>, use: bool)
}

impl OpError {
  fn Error(self: Ref<OpError>) -> string

  fn Temporary(self: Ref<OpError>) -> bool

  fn Timeout(self: Ref<OpError>) -> bool

  fn Unwrap(self: Ref<OpError>) -> Option<error>
}

impl ParseError {
  fn Error(self: Ref<ParseError>) -> string

  fn Temporary(self: Ref<ParseError>) -> bool

  fn Timeout(self: Ref<ParseError>) -> bool
}

impl Resolver {
  /// LookupAddr performs a reverse lookup for the given address, returning a list
  /// of names mapping to that address.
  /// 
  /// The returned names are validated to be properly formatted presentation-format
  /// domain names. If the response contains invalid names, those records are filtered
  /// out and an error will be returned alongside the remaining results, if any.
  fn LookupAddr(self: Ref<Resolver>, ctx: context.Context, addr: string) -> Result<Slice<string>, error>

  /// LookupCNAME returns the canonical name for the given host.
  /// Callers that do not care about the canonical name can call
  /// [LookupHost] or [LookupIP] directly; both take care of resolving
  /// the canonical name as part of the lookup.
  /// 
  /// A canonical name is the final name after following zero
  /// or more CNAME records.
  /// LookupCNAME does not return an error if host does not
  /// contain DNS "CNAME" records, as long as host resolves to
  /// address records.
  /// 
  /// The returned canonical name is validated to be a properly
  /// formatted presentation-format domain name.
  fn LookupCNAME(self: Ref<Resolver>, ctx: context.Context, host: string) -> Result<string, error>

  /// LookupHost looks up the given host using the local resolver.
  /// It returns a slice of that host's addresses.
  fn LookupHost(self: Ref<Resolver>, ctx: context.Context, host: string) -> Result<Slice<string>, error>

  /// LookupIP looks up host for the given network using the local resolver.
  /// It returns a slice of that host's IP addresses of the type specified by
  /// network.
  /// network must be one of "ip", "ip4" or "ip6".
  fn LookupIP(
    self: Ref<Resolver>,
    ctx: context.Context,
    network: string,
    host: string,
  ) -> Result<Slice<IP>, error>

  /// LookupIPAddr looks up host using the local resolver.
  /// It returns a slice of that host's IPv4 and IPv6 addresses.
  fn LookupIPAddr(self: Ref<Resolver>, ctx: context.Context, host: string) -> Result<Slice<IPAddr>, error>

  /// LookupMX returns the DNS MX records for the given domain name sorted by preference.
  /// 
  /// The returned mail server names are validated to be properly
  /// formatted presentation-format domain names, or numeric IP addresses.
  /// If the response contains invalid names, those records are filtered out
  /// and an error will be returned alongside the remaining results, if any.
  fn LookupMX(self: Ref<Resolver>, ctx: context.Context, name: string) -> Result<Slice<Ref<MX>>, error>

  /// LookupNS returns the DNS NS records for the given domain name.
  /// 
  /// The returned name server names are validated to be properly
  /// formatted presentation-format domain names. If the response contains
  /// invalid names, those records are filtered out and an error
  /// will be returned alongside the remaining results, if any.
  fn LookupNS(self: Ref<Resolver>, ctx: context.Context, name: string) -> Result<Slice<Ref<NS>>, error>

  /// LookupNetIP looks up host using the local resolver.
  /// It returns a slice of that host's IP addresses of the type specified by
  /// network.
  /// The network must be one of "ip", "ip4" or "ip6".
  fn LookupNetIP(
    self: Ref<Resolver>,
    ctx: context.Context,
    network: string,
    host: string,
  ) -> Result<Slice<netip.Addr>, error>

  /// LookupPort looks up the port for the given network and service.
  /// 
  /// The network must be one of "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6" or "ip".
  fn LookupPort(
    self: Ref<Resolver>,
    ctx: context.Context,
    network: string,
    service: string,
  ) -> Result<int, error>

  /// LookupSRV tries to resolve an [SRV] query of the given service,
  /// protocol, and domain name. The proto is "tcp" or "udp".
  /// The returned records are sorted by priority and randomized
  /// by weight within a priority.
  /// 
  /// LookupSRV constructs the DNS name to look up following RFC 2782.
  /// That is, it looks up _service._proto.name. To accommodate services
  /// publishing SRV records under non-standard names, if both service
  /// and proto are empty strings, LookupSRV looks up name directly.
  /// 
  /// The returned service names are validated to be properly
  /// formatted presentation-format domain names. If the response contains
  /// invalid names, those records are filtered out and an error
  /// will be returned alongside the remaining results, if any.
  fn LookupSRV(
    self: Ref<Resolver>,
    ctx: context.Context,
    service: string,
    proto: string,
    name: string,
  ) -> Result<(string, Slice<Ref<SRV>>), error>

  /// LookupTXT returns the DNS TXT records for the given domain name.
  /// 
  /// If a DNS TXT record holds multiple strings, they are concatenated as a
  /// single string.
  fn LookupTXT(self: Ref<Resolver>, ctx: context.Context, name: string) -> Result<Slice<string>, error>
}

impl TCPAddr {
  /// AddrPort returns the [TCPAddr] a as a [netip.AddrPort].
  /// 
  /// If a.Port does not fit in a uint16, it's silently truncated.
  /// 
  /// If a is nil, a zero value is returned.
  fn AddrPort(self: Ref<TCPAddr>) -> netip.AddrPort

  /// Network returns the address's network name, "tcp".
  fn Network(self: Ref<TCPAddr>) -> string

  fn String(self: Ref<TCPAddr>) -> string
}

impl TCPConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<TCPConn>) -> Result<(), error>

  /// CloseRead shuts down the reading side of the TCP connection.
  /// Most callers should just use Close.
  fn CloseRead(self: Ref<TCPConn>) -> Result<(), error>

  /// CloseWrite shuts down the writing side of the TCP connection.
  /// Most callers should just use Close.
  fn CloseWrite(self: Ref<TCPConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<TCPConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<TCPConn>) -> Addr

  /// MultipathTCP reports whether the ongoing connection is using MPTCP.
  /// 
  /// If Multipath TCP is not supported by the host, by the other peer or
  /// intentionally / accidentally filtered out by a device in between, a
  /// fallback to TCP will be done. This method does its best to check if
  /// MPTCP is still being used or not.
  /// 
  /// On Linux, more conditions are verified on kernels >= v5.16, improving
  /// the results.
  fn MultipathTCP(self: Ref<TCPConn>) -> Result<bool, error>

  /// Read implements the Conn Read method.
  fn Read(self: Ref<TCPConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [io.ReaderFrom] ReadFrom method.
  fn ReadFrom(self: Ref<TCPConn>, r: io.Reader) -> Result<int64, error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<TCPConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<TCPConn>, t: time.Time) -> Result<(), error>

  /// SetKeepAlive sets whether the operating system should send
  /// keep-alive messages on the connection.
  fn SetKeepAlive(self: Ref<TCPConn>, keepalive: bool) -> Result<(), error>

  /// SetKeepAliveConfig configures keep-alive messages sent by the operating system.
  fn SetKeepAliveConfig(self: Ref<TCPConn>, config: KeepAliveConfig) -> Result<(), error>

  /// SetKeepAlivePeriod sets the duration the connection needs to
  /// remain idle before TCP starts sending keepalive probes.
  /// 
  /// Note that calling this method on Windows prior to Windows 10 version 1709
  /// will reset the KeepAliveInterval to the default system value, which is normally 1 second.
  fn SetKeepAlivePeriod(self: Ref<TCPConn>, d: time.Duration) -> Result<(), error>

  /// SetLinger sets the behavior of Close on a connection which still
  /// has data waiting to be sent or to be acknowledged.
  /// 
  /// If sec < 0 (the default), the operating system finishes sending the
  /// data in the background.
  /// 
  /// If sec == 0, the operating system discards any unsent or
  /// unacknowledged data.
  /// 
  /// If sec > 0, the data is sent in the background as with sec < 0.
  /// On some operating systems including Linux, this may cause Close to block
  /// until all data has been sent or discarded.
  /// On some operating systems after sec seconds have elapsed any remaining
  /// unsent data may be discarded.
  fn SetLinger(self: Ref<TCPConn>, sec: int) -> Result<(), error>

  /// SetNoDelay controls whether the operating system should delay
  /// packet transmission in hopes of sending fewer packets (Nagle's
  /// algorithm).  The default is true (no delay), meaning that data is
  /// sent as soon as possible after a Write.
  fn SetNoDelay(self: Ref<TCPConn>, noDelay: bool) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<TCPConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<TCPConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<TCPConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<TCPConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<TCPConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<TCPConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteTo implements the io.WriterTo WriteTo method.
  fn WriteTo(self: Ref<TCPConn>, w: io.Writer) -> Result<int64, error>
}

impl TCPListener {
  /// Accept implements the Accept method in the [Listener] interface; it
  /// waits for the next call and returns a generic [Conn].
  fn Accept(self: Ref<TCPListener>) -> Result<Conn, error>

  /// AcceptTCP accepts the next incoming call and returns the new
  /// connection.
  fn AcceptTCP(self: Ref<TCPListener>) -> Result<Ref<TCPConn>, error>

  /// Addr returns the listener's network address, a [*TCPAddr].
  /// The Addr returned is shared by all invocations of Addr, so
  /// do not modify it.
  fn Addr(self: Ref<TCPListener>) -> Addr

  /// Close stops listening on the TCP address.
  /// Already Accepted connections are not closed.
  #[allow(unused_result)]
  fn Close(self: Ref<TCPListener>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing l does not affect f, and closing f does not affect l.
  /// 
  /// The returned os.File's file descriptor is different from the
  /// connection's. Attempting to change properties of the original
  /// using this duplicate may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not
  /// usable on other processes.
  fn File(self: Ref<TCPListener>) -> Result<Ref<os.File>, error>

  /// SetDeadline sets the deadline associated with the listener.
  /// A zero time value disables the deadline.
  fn SetDeadline(self: Ref<TCPListener>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  /// 
  /// The returned RawConn only supports calling Control. Read and
  /// Write return an error.
  fn SyscallConn(self: Ref<TCPListener>) -> Result<syscall.RawConn, error>
}

impl UDPAddr {
  /// AddrPort returns the [UDPAddr] a as a [netip.AddrPort].
  /// 
  /// If a.Port does not fit in a uint16, it's silently truncated.
  /// 
  /// If a is nil, a zero value is returned.
  fn AddrPort(self: Ref<UDPAddr>) -> netip.AddrPort

  /// Network returns the address's network name, "udp".
  fn Network(self: Ref<UDPAddr>) -> string

  fn String(self: Ref<UDPAddr>) -> string
}

impl UDPConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<UDPConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<UDPConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<UDPConn>) -> Addr

  /// Read implements the Conn Read method.
  fn Read(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [PacketConn] ReadFrom method.
  fn ReadFrom(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Result<(int, Addr), error>

  /// ReadFromUDP acts like [UDPConn.ReadFrom] but returns a UDPAddr.
  fn ReadFromUDP(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Result<(int, Ref<UDPAddr>), error>

  /// ReadFromUDPAddrPort acts like ReadFrom but returns a [netip.AddrPort].
  /// 
  /// If c is bound to an unspecified address, the returned
  /// netip.AddrPort's address might be an IPv4-mapped IPv6 address.
  /// Use [netip.Addr.Unmap] to get the address without the IPv6 prefix.
  fn ReadFromUDPAddrPort(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Result<(int, netip.AddrPort), error>

  /// ReadMsgUDP reads a message from c, copying the payload into b and
  /// the associated out-of-band data into oob. It returns the number of
  /// bytes copied into b, the number of bytes copied into oob, the flags
  /// that were set on the message and the source address of the message.
  /// 
  /// The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be
  /// used to manipulate IP-level socket options in oob.
  fn ReadMsgUDP(self: Ref<UDPConn>, mut b: Slice<uint8>, mut oob: Slice<uint8>) -> Result<(int, int, int, Ref<UDPAddr>), error>

  /// ReadMsgUDPAddrPort is like [UDPConn.ReadMsgUDP] but returns an [netip.AddrPort] instead of a [UDPAddr].
  fn ReadMsgUDPAddrPort(
    self: Ref<UDPConn>,
    mut b: Slice<uint8>,
    mut oob: Slice<uint8>,
  ) -> Result<(int, int, int, netip.AddrPort), error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<UDPConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<UDPConn>, t: time.Time) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<UDPConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<UDPConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<UDPConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<UDPConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<UDPConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<UDPConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteMsgUDP writes a message to addr via c if c isn't connected, or
  /// to c's remote address if c is connected (in which case addr must be
  /// nil). The payload is copied from b and the associated out-of-band
  /// data is copied from oob. It returns the number of payload and
  /// out-of-band bytes written.
  /// 
  /// The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be
  /// used to manipulate IP-level socket options in oob.
  fn WriteMsgUDP(
    self: Ref<UDPConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: Ref<UDPAddr>,
  ) -> Result<(int, int), error>

  /// WriteMsgUDPAddrPort is like [UDPConn.WriteMsgUDP] but takes a [netip.AddrPort] instead of a [UDPAddr].
  fn WriteMsgUDPAddrPort(
    self: Ref<UDPConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: netip.AddrPort,
  ) -> Result<(int, int), error>

  /// WriteTo implements the [PacketConn] WriteTo method.
  fn WriteTo(self: Ref<UDPConn>, b: Slice<uint8>, addr: Addr) -> Result<int, error>

  /// WriteToUDP acts like [UDPConn.WriteTo] but takes a [UDPAddr].
  fn WriteToUDP(self: Ref<UDPConn>, b: Slice<uint8>, addr: Ref<UDPAddr>) -> Result<int, error>

  /// WriteToUDPAddrPort acts like [UDPConn.WriteTo] but takes a [netip.AddrPort].
  fn WriteToUDPAddrPort(
    self: Ref<UDPConn>,
    b: Slice<uint8>,
    addr: netip.AddrPort,
  ) -> Result<int, error>
}

impl UnixAddr {
  /// Network returns the address's network name, "unix", "unixgram" or
  /// "unixpacket".
  fn Network(self: Ref<UnixAddr>) -> string

  fn String(self: Ref<UnixAddr>) -> string
}

impl UnixConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<UnixConn>) -> Result<(), error>

  /// CloseRead shuts down the reading side of the Unix domain connection.
  /// Most callers should just use [UnixConn.Close].
  fn CloseRead(self: Ref<UnixConn>) -> Result<(), error>

  /// CloseWrite shuts down the writing side of the Unix domain connection.
  /// Most callers should just use [UnixConn.Close].
  fn CloseWrite(self: Ref<UnixConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<UnixConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<UnixConn>) -> Addr

  /// Read implements the Conn Read method.
  fn Read(self: Ref<UnixConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [PacketConn].ReadFrom method.
  fn ReadFrom(self: Ref<UnixConn>, mut b: Slice<uint8>) -> Result<(int, Addr), error>

  /// ReadFromUnix acts like [UnixConn.ReadFrom] but returns a [UnixAddr].
  fn ReadFromUnix(self: Ref<UnixConn>, mut b: Slice<uint8>) -> Result<(int, Ref<UnixAddr>), error>

  /// ReadMsgUnix reads a message from c, copying the payload into b and
  /// the associated out-of-band data into oob. It returns the number of
  /// bytes copied into b, the number of bytes copied into oob, the flags
  /// that were set on the message and the source address of the message.
  /// 
  /// Note that if len(b) == 0 and len(oob) > 0, this function will still
  /// read (and discard) 1 byte from the connection.
  fn ReadMsgUnix(
    self: Ref<UnixConn>,
    mut b: Slice<uint8>,
    mut oob: Slice<uint8>,
  ) -> Result<(int, int, int, Ref<UnixAddr>), error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<UnixConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<UnixConn>, t: time.Time) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<UnixConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<UnixConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<UnixConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<UnixConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<UnixConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<UnixConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteMsgUnix writes a message to addr via c, copying the payload
  /// from b and the associated out-of-band data from oob. It returns the
  /// number of payload and out-of-band bytes written.
  /// 
  /// Note that if len(b) == 0 and len(oob) > 0, this function will still
  /// write 1 byte to the connection.
  fn WriteMsgUnix(
    self: Ref<UnixConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: Ref<UnixAddr>,
  ) -> Result<(int, int), error>

  /// WriteTo implements the [PacketConn].WriteTo method.
  fn WriteTo(self: Ref<UnixConn>, b: Slice<uint8>, addr: Addr) -> Result<int, error>

  /// WriteToUnix acts like [UnixConn.WriteTo] but takes a [UnixAddr].
  fn WriteToUnix(self: Ref<UnixConn>, b: Slice<uint8>, addr: Ref<UnixAddr>) -> Result<int, error>
}

impl UnixListener {
  /// Accept implements the Accept method in the [Listener] interface.
  /// Returned connections will be of type [*UnixConn].
  fn Accept(self: Ref<UnixListener>) -> Result<Conn, error>

  /// AcceptUnix accepts the next incoming call and returns the new
  /// connection.
  fn AcceptUnix(self: Ref<UnixListener>) -> Result<Ref<UnixConn>, error>

  /// Addr returns the listener's network address.
  /// The [Addr] returned is shared by all invocations of Addr, so
  /// do not modify it.
  fn Addr(self: Ref<UnixListener>) -> Addr

  /// Close stops listening on the Unix address. Already accepted
  /// connections are not closed.
  #[allow(unused_result)]
  fn Close(self: Ref<UnixListener>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing l does not affect f, and closing f does not affect l.
  /// 
  /// The returned [os.File]'s file descriptor is different from the
  /// connection's. Attempting to change properties of the original
  /// using this duplicate may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not
  /// usable on other processes.
  fn File(self: Ref<UnixListener>) -> Result<Ref<os.File>, error>

  /// SetDeadline sets the deadline associated with the listener.
  /// A zero time value disables the deadline.
  fn SetDeadline(self: Ref<UnixListener>, t: time.Time) -> Result<(), error>

  /// SetUnlinkOnClose sets whether the underlying socket file should be removed
  /// from the file system when the listener is closed.
  /// 
  /// The default behavior is to unlink the socket file only when package net created it.
  /// That is, when the listener and the underlying socket file were created by a call to
  /// Listen or ListenUnix, then by default closing the listener will remove the socket file.
  /// but if the listener was created by a call to FileListener to use an already existing
  /// socket file, then by default closing the listener will not remove the socket file.
  fn SetUnlinkOnClose(self: Ref<UnixListener>, unlink: bool)

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  /// 
  /// The returned [syscall.RawConn] only supports calling Control. Read and
  /// Write return an error.
  fn SyscallConn(self: Ref<UnixListener>) -> Result<syscall.RawConn, error>
}

impl UnknownNetworkError {
  fn Error(self) -> string

  fn Temporary(self) -> bool

  fn Timeout(self) -> bool
}
