Reference · generated from the interface
Every public name,
with the comment above it.
Built from the interface the compiler emits and the doc comments in the sources, so a function that is documented is a function that is here. One package, five groups.
Address
Addr · 42 entriesOne address: IPv4 or IPv6, with the zone a scoped IPv6 address may carry.
pub struct Addr
An IPv4 or IPv6 address, and the zone an IPv6 scoped address may carry. The value never changes once made, compares by its bits, and can be a key in a map. IPv4 keeps its 32 bits in the low word with v4 set, so 1.2.3.4 and ::1.2.3.4 are two different addresses that never compare equal.
hi : UInt64 lo : UInt64 v4 : Bool zone : String?
also @debug.Debug, Compare, Eq, Hash, Show
pub fn Addr::bits(Self) -> Int32
How many bits the address has: 32 for IPv4, 128 for IPv6.
pub fn Addr::compare(Self, Self) -> Int32
pub fn Addr::decode(BytesView) -> Self raise Refused
Read the address back from four (IPv4) or sixteen (IPv6) bytes.
pub fn Addr::encode(Self) -> Bytes
The four or sixteen bytes of the address, big-endian, the way a packet or a certificate option carries them. A zone is not part of the address and is not written.
pub fn Addr::equal(Self, Self) -> Bool
pub fn Addr::exploded(Self) -> String
Every group written out in full, four hexadecimal digits each, with nothing compressed. Handy for anything that compares text rather than reads it: two addresses are equal exactly when their exploded forms are.
pub fn Addr::hash(Self) -> Int32
pub fn Addr::hash_combine(Self, Hasher) -> Unit
pub fn Addr::is_global(Self) -> Bool
Whether the address is globally reachable: the opposite of is_private, except for shared address space 100.64.0.0/10, which is neither private nor reachable and so answers false to both.
pub fn Addr::is_interface_local_multicast(Self) -> Bool
Whether this is an interface-local multicast address, ff01::/16 (RFC 4291 section 2.7). The scope says the packet never leaves the interface it was sent on, which is why IPv4, whose multicast has no such scope, is always false.
pub fn Addr::is_link_local(Self) -> Bool
Whether this is a link-local address: 169.254.0.0/16 for IPv4 (RFC 3927), fe80::/10 for IPv6.
pub fn Addr::is_link_local_multicast(Self) -> Bool
Whether this is a link-local multicast address: 224.0.0.0/24 for IPv4, ff02::/16 for IPv6. is_link_local is the unicast counterpart.
pub fn Addr::is_loopback(Self) -> Bool
Whether this is a loopback address: 127.0.0.0/8 for IPv4, ::1 for IPv6.
pub fn Addr::is_multicast(Self) -> Bool
Whether this is a multicast address: 224.0.0.0/4 for IPv4, ff00::/8 for IPv6.
pub fn Addr::is_private(Self) -> Bool
Whether the address sits in a block the IANA registries mark as not globally reachable: the private-use ranges, loopback, link local, documentation, benchmarking and the rest, with the IPv6 exceptions the registry itself names.
pub fn Addr::is_reserved(Self) -> Bool
Whether this address is reserved for a purpose other than unicast: 240.0.0.0/4 for IPv4, and for IPv6 every block outside 2000::/3 and fe80::/10 (RFC 4291 section 2.4).
pub fn Addr::is_site_local(Self) -> Bool
Whether this is a deprecated site-local address, fec0::/10 (RFC 3879). IPv4 has no such thing, so it is always false there.
pub fn Addr::is_unspecified(Self) -> Bool
Whether this is the unspecified address, 0.0.0.0 or ::. An IPv4-mapped address is judged by the IPv4 address inside it, like every other question here.
pub fn Addr::is_v4(Self) -> Bool
Whether this is an IPv4 address.
pub fn Addr::is_v4_mapped(Self) -> Bool
Whether this is an IPv4-mapped IPv6 address, that is, one in ::ffff:0:0/96.
pub fn Addr::is_v6(Self) -> Bool
Whether this is an IPv6 address. An IPv4-mapped address such as ::ffff:192.0.2.1 is IPv6 here; unmap is how it becomes IPv4.
pub fn Addr::mapped(Self) -> Self
The IPv4-mapped IPv6 form of an IPv4 address; a real IPv6 address comes back unchanged.
pub fn Addr::next(Self) -> Self?
The next address, or None at the top of the family.
pub fn Addr::not_equal(Self, Self) -> Bool
pub fn Addr::op_ge(Self, Self) -> Bool
pub fn Addr::op_gt(Self, Self) -> Bool
pub fn Addr::op_le(Self, Self) -> Bool
pub fn Addr::op_lt(Self, Self) -> Bool
pub fn Addr::output(Self, &Logger) -> Unit
pub fn Addr::parse(StringView) -> Self raise Refused
Read an address out of its text form: four dotted decimal fields, or the colon form of RFC 4291 with an optional %zone.
pub fn Addr::prev(Self) -> Self?
The address before this one, or None at the bottom of the family.
pub fn Addr::reverse_pointer(Self) -> String
The name this address has in the reverse DNS tree: 4.3.2.1.in-addr.arpa for IPv4, and the thirty-two nibbles of the address in reverse order under ip6.arpa for IPv6 (RFC 3596).
pub fn Addr::sixtofour(Self) -> Self?
The IPv4 address carried by a 6to4 address, 2002::/16 (RFC 3056).
pub fn Addr::teredo(Self) -> (Self, Self)?
The server and client addresses carried by a Teredo address, 2001::/32 (RFC 4380). The client is stored inverted (RFC 5991), so the last 32 bits are read as a complement.
pub fn Addr::to_repr(Self) -> @debug.Repr
pub fn Addr::to_string(Self) -> String
pub fn Addr::unmap(Self) -> Self
The IPv4 address inside an IPv4-mapped IPv6 one; anything else comes back unchanged. The zone goes with the IPv6 form and is dropped.
pub fn Addr::v4(Byte, Byte, Byte, Byte) -> Self
An IPv4 address from its four octets.
pub fn Addr::v6(UInt64, UInt64) -> Self
An IPv6 address from its two halves: hi the top 64 bits, lo the bottom 64.
pub fn Addr::with_zone(Self, String?) -> Self
The same address on another zone. A zone only means something to a scoped IPv6 address, so on IPv4 this returns the address unchanged.
pub fn Addr::zone(Self) -> String?
The zone (RFC 4007), when the address came with one.
Block
Prefix · 31 entriesAn address and a mask length. Keeps the address it was written with.
pub struct Prefix
A network: an address and the number of leading bits that all addresses in it share, written 192.0.2.0/24. The address is kept as it was given, so 192.0.2.5/24 stands for "this host on that link" the way an interface does; every question about the block itself works on masked, which is the same prefix with the host bits cleared.
net : Addr plen : Int32
also @debug.Debug, Compare, Eq, Hash, Show
pub fn Prefix::addr(Self) -> Addr
The address as written, host bits and all.
pub fn Prefix::bits(Self) -> Int32
The length of the mask in bits: 0 to 32 for IPv4, 0 to 128 for IPv6.
pub fn Prefix::broadcast(Self) -> Addr?
The last address of the block, or None for IPv6, which has no broadcast address: the top of an IPv6 block is an ordinary unicast address.
pub fn Prefix::compare(Self, Self) -> Int32
pub fn Prefix::contains(Self, Addr) -> Bool
Whether the address falls inside the block. An IPv4-mapped IPv6 address is matched against IPv6 blocks only; unmap first if you mean the IPv4 one.
pub fn Prefix::equal(Self, Self) -> Bool
pub fn Prefix::exclude(Self, Self) -> Array[Self] raise Refused
The parts of this block that the other one does not cover, largest first. The other block only has to share the family; a block that merely touches this one at the edge leaves it whole, one that covers it leaves nothing, and one that sits over part of it leaves the surround. So the answer is always the exact difference, whatever the caller passes.
pub fn Prefix::hash(Self) -> Int32
pub fn Prefix::hash_combine(Self, Hasher) -> Unit
pub fn Prefix::hostmask(Self) -> Addr
The complement of the mask, 0.0.0.255 or ::ffff:ffff:ffff:ffff.
pub fn Prefix::hosts(Self) -> Iter[Addr]
The addresses that can be given to an interface in the block. For IPv4 that is every address except the network and broadcast ones, with a /31 (RFC 3021) and a /32 kept whole because both ends are usable there. For IPv6 it is every address except the subnet-router anycast address at the bottom, with a /127 and a /128 kept whole. The iterator is lazy; a /0 has a great many addresses and no one wants them in an array.
pub fn Prefix::is_single_ip(Self) -> Bool
Whether the block is a single address, that is, a /32 or a /128.
pub fn Prefix::is_subnet_of(Self, Self) -> Bool
Whether this block sits inside the other one, equal blocks included.
pub fn Prefix::is_supernet_of(Self, Self) -> Bool
Whether this block holds the other one, equal blocks included. The same test as is_subnet_of with the two sides the other way round, for callers who read better that way.
pub fn Prefix::masked(Self) -> Self
The block itself: the address with every bit below the mask cleared.
pub fn Prefix::netmask(Self) -> Addr
The mask as an address, 255.255.255.0 or ffff:ffff:ffff:ffff::.
pub fn Prefix::new(Addr, Int32) -> Self raise Refused
A prefix from an address and a length. The address is kept whole; use masked to turn it into the network it names.
pub fn Prefix::not_equal(Self, Self) -> Bool
pub fn Prefix::num_addresses(Self) -> UInt64?
How many addresses the block holds, or None when that is more than a UInt64 can count: an IPv6 block shorter than /64. An IPv4 block always answers, 0.0.0.0/0 with 4294967296.
pub fn Prefix::op_ge(Self, Self) -> Bool
pub fn Prefix::op_gt(Self, Self) -> Bool
pub fn Prefix::op_le(Self, Self) -> Bool
pub fn Prefix::op_lt(Self, Self) -> Bool
pub fn Prefix::output(Self, &Logger) -> Unit
pub fn Prefix::overlaps(Self, Self) -> Bool
Whether two blocks share at least one address. Blocks of different families never do.
pub fn Prefix::parse(StringView, strict? : Bool) -> Self raise Refused
Read a prefix from address/length. With strict on, bits set below the mask are refused; with it off they are cleared, which is how a block is usually written by hand.
pub fn Prefix::subnets(Self, bits~ : Int32) -> Iter[Self] raise Refused
The blocks of length bits that together make up this one, in ascending order.
pub fn Prefix::supernet(Self, bits~ : Int32) -> Self raise Refused
The block of length bits that contains this one.
pub fn Prefix::to_repr(Self) -> @debug.Repr
pub fn Prefix::to_string(Self) -> String
Address and port
AddrPort · 18 entriesOne end of a conversation.
pub struct AddrPort
An address and a port: one end of a TCP or UDP conversation.
addr : Addr port : Int32
also @debug.Debug, Compare, Eq, Hash, Show
pub fn AddrPort::addr(Self) -> Addr
The address half.
pub fn AddrPort::compare(Self, Self) -> Int32
pub fn AddrPort::equal(Self, Self) -> Bool
pub fn AddrPort::hash(Self) -> Int32
pub fn AddrPort::hash_combine(Self, Hasher) -> Unit
pub fn AddrPort::new(Addr, Int32) -> Self raise Refused
An address and a port, the port being 0 to 65535.
pub fn AddrPort::not_equal(Self, Self) -> Bool
pub fn AddrPort::op_ge(Self, Self) -> Bool
pub fn AddrPort::op_gt(Self, Self) -> Bool
pub fn AddrPort::op_le(Self, Self) -> Bool
pub fn AddrPort::op_lt(Self, Self) -> Bool
pub fn AddrPort::output(Self, &Logger) -> Unit
pub fn AddrPort::parse(StringView) -> Self raise Refused
Read 1.2.3.4:80 or [::1]:80. The brackets around an IPv6 address are what tells the last colon from the ones in the address, so an IPv6 address without them is refused rather than guessed at.
pub fn AddrPort::port(Self) -> Int32
The port half, 0 to 65535.
pub fn AddrPort::to_repr(Self) -> @debug.Repr
pub fn AddrPort::to_string(Self) -> String
pub fn AddrPort::with_port(Self, Int32) -> Self raise Refused
The same address on another port, for a proxy that rewrites one half of an end.
Refusal
Refused · 3 entriesWhy a text form, a byte string or an argument pair was refused.
pub struct Refused
Why a text form, a byte string or an argument pair was refused. Every call that can refuse reports one of these rather than a boolean, so the caller can tell a typo from a number that was merely too large.
Malformed(at~ : Int32) OutOfRange(limit~ : Int32, got~ : Int32) Length(want~ : Int32, got~ : Int32) HostBits Family Reversed
also Show
pub fn Refused::output(Self, &Logger) -> Unit
pub fn Refused::to_string(Self) -> String
Free functions
6 entriesBlock arithmetic that belongs to no one type: a range joined back up, and a set of blocks collapsed.
pub fn collapse(ArrayView[Prefix]) -> Array[Prefix]
The fewest blocks that hold exactly the same addresses as the ones given. Blocks of different families are collapsed separately and the IPv4 ones come first, so the answer is always exact even though a mix of families has no single ordering.
pub let loopback4 : Addr
127.0.0.1, the near end of the loopback range.
pub let loopback6 : Addr
::1, the only loopback address IPv6 has.
pub fn summarize(Addr, Addr) -> Array[Prefix] raise Refused
The fewest blocks that hold exactly the addresses from first to last.
pub let unspecified4 : Addr
0.0.0.0, the address that means "this host, no address yet".
pub let unspecified6 : Addr
::, the same idea in IPv6.