Prefix

typePrefix

An IP address prefix: the combination of an IP address and a prefix length

A prefix can be constructed with the / operator or with the Prefix.new function. This operator takes an IpAddr and a u8 as operands.

1.1.1.0 / 8
192.0.0.0.0 / 24
functionaddr(self: Prefix) IpAddr

Returns the IP address part of a prefix.

functioneq(self: Prefix, other: Prefix) bool

Check whether those prefixes are the same

functionlen(self: Prefix) u8

Returns the length part of a prefix.

functionmax_addr(self: Prefix) IpAddr

Returns the largest address of the prefix.

functionmin_addr(self: Prefix) IpAddr

Returns the smallest address of the prefix.

This is the same as Prefix.addr.

functionnew(ip: IpAddr, len: u8) Prefix

Construct a new prefix

A prefix can also be constructed with the / operator.

Prefix.new(192.169.0.0, 16)

# or equivalently
192.169.0.0 / 16
functionto_string(self: Prefix) String

Convert this value into a String