Struct Ipv6Prefix120 Copy item path Source #[repr(C)]
pub struct Ipv6Prefix120 { }Expand description An Ipv6 prefix limited to 120 bits and encoded as u128 (EXPERIMENTAL)
In many applications, managed Ipv6 prefixes are never longer than 120 bits.
In theses cases, it is possible to save memory space by encoding it in
128 bits with its length encoded in last byte.
|---------------------- 120 bits -----------------------|--8 bits--|
ip prefix slot length
The resulting prefix is twice as short as the corresponding Ipv6 generic prefix.
Creates a prefix from a well structured slot.
A well-structured slot is structured as follows where length is
encoded on the last byte (8 bits) and this length should not
exceed the prefix limit Self::MAX_LEN .
|------------ ip prefix slot ------------|-- length --|§ Safety
Results are unpredictable if the last byte is not a valid length
(i.e. exceeds Self::MAX_LEN )
A safe version of this function exists as Self::from_slot
or also [`Self::try_from_slot] which doesn’t panic.
§ Example
let prefix = "1:1::/48" .parse::<Ipv6Prefix56>().unwrap();
let slot : u64 = prefix.into_slot();
assert_eq! ( prefix, unsafe { Ipv6Prefix56::from_slot_unchecked(slot)});
let prefix = "1:1::/48" .parse::<Ipv6Prefix120>().unwrap();
let slot : u128 = prefix.into_slot();
assert_eq! ( prefix, unsafe { Ipv6Prefix120::from_slot_unchecked(slot)});
Creates a prefix from a well structured slot.
A well-structured slot is structured as follows where length is
encoded on the last byte (8 bits) and this length should not
exceed the prefix limit Self::MAX_LEN .
|------------ ip prefix slot ------------|-- length --|
It returns an error if the last byte is not a valid length.
If you are sure that the slot is well-structured, an unchecked
(and unsafe) version of this function is provided by Self::from_slot_unchecked .
§ Example
let prefix = "1:1::/48" .parse::<Ipv6Prefix56>().unwrap();
let slot : u64 = prefix.into_slot();
assert_eq! ( Ok (prefix), Ipv6Prefix56::from_slot(slot));
let prefix = "1:1::/48" .parse::<Ipv6Prefix120>().unwrap();
let slot : u128 = prefix.into_slot();
assert_eq! ( Ok (prefix), Ipv6Prefix120::from_slot(slot));
Gets the raw value of the inner slot.
This slot is structured as follows where length is
encoded on the last byte (8 bits).
|------------ ip prefix slot ------------|-- length --|
The returned slot could be safely used with Self::from_slot_unchecked .
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more Returns the “default value” for a type.
Read more Formats the value using the given formatter.
Read more Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string
s to return a value of this type.
Read more The maximum allowed length for this prefix
The slot manipulated inside this prefix
The underlying ip address (usually Ipv4Addr or Ipv6Addr)
The inner slot with all the masked bits set to 0.
Read more The address of the network defined by the prefixv
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Checks the coverage of this prefix against a set of addresses
Read more Root prefix has a length of 0
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dst.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
Checks the coverage of this prefix against a set of addresses
Read more The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more Converts the given value to a
String.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.