pub trait Address<A: Afi>: Copy + Debug + Default + Hash + Ord + BitAnd<Self, Output = Self> + BitOr<Self, Output = Self> + BitXor<Self, Output = Self> + Add<Self, Output = Self> + CheckedAdd + Not<Output = Self> + Shl<Self::Length, Output = Self> + Shr<Self::Length, Output = Self> + 'static {
type Length: Length;
type LengthMap: LengthMap;
Show 18 associated constants and 7 methods
const MAX_LENGTH: Self::Length;
const ZERO: Self;
const ONES: Self;
const BROADCAST: Option<Self>;
const LOCALHOST: Self;
const UNSPECIFIED: Self;
const LOOPBACK_RANGE: RangeInclusive<Self>;
const BENCHMARK_RANGE: RangeInclusive<Self>;
const MULTICAST_RANGE: RangeInclusive<Self>;
const LINK_LOCAL_RANGE: RangeInclusive<Self>;
const PROTOCOL_ASSIGNMENTS_RANGE: RangeInclusive<Self>;
const DOCUMENTATION_RANGES: &'static [RangeInclusive<Self>];
const PRIVATE_RANGES: Option<&'static [RangeInclusive<Self>]>;
const RESERVED_RANGE: Option<RangeInclusive<Self>>;
const SHARED_RANGE: Option<RangeInclusive<Self>>;
const THISNET_RANGE: Option<RangeInclusive<Self>>;
const ULA_RANGE: Option<RangeInclusive<Self>>;
const MIN_LENGTH: Self::Length = <Self::Length>::ZERO;
// Required methods
fn leading_zeros(self) -> Self::Length;
fn to_be_bytes(self) -> A::Octets;
fn from_be_bytes(bytes: A::Octets) -> Self;
fn is_global(&self) -> bool;
fn parse_addr<S>(s: &S) -> Result<Self, Error>
where S: AsRef<str> + ?Sized;
fn parse_prefix<S>(s: &S) -> Result<(Self, Self::Length), Error>
where S: AsRef<str> + ?Sized;
fn parse_range<S>(
s: &S
) -> Result<(Self, Self::Length, Self::Length, Self::Length), Error>
where S: AsRef<str> + ?Sized;
}Expand description
Underlying integer-like type used to represent an IP address.
Required Associated Types§
Required Associated Constants§
sourceconst MAX_LENGTH: Self::Length
const MAX_LENGTH: Self::Length
Maximum valid value of the underlying primitive value used to store prefix-lengths for this address-family.
sourceconst BROADCAST: Option<Self>
const BROADCAST: Option<Self>
The primitive value of the subnet-local broadcast address, if it is defined for the address family.
sourceconst UNSPECIFIED: Self
const UNSPECIFIED: Self
The primitive value of the “unspecified” address for this address family.
sourceconst LOOPBACK_RANGE: RangeInclusive<Self>
const LOOPBACK_RANGE: RangeInclusive<Self>
The range of primitive address values defined for “loopback” use for this address family.
sourceconst BENCHMARK_RANGE: RangeInclusive<Self>
const BENCHMARK_RANGE: RangeInclusive<Self>
The range of primitive address values defined for “benchmarking” use for this address family.
sourceconst MULTICAST_RANGE: RangeInclusive<Self>
const MULTICAST_RANGE: RangeInclusive<Self>
The range of primitive address values defined for “multicast” use for this address family.
sourceconst LINK_LOCAL_RANGE: RangeInclusive<Self>
const LINK_LOCAL_RANGE: RangeInclusive<Self>
The range of primitive address values defined for “link-local” use for this address family.
sourceconst PROTOCOL_ASSIGNMENTS_RANGE: RangeInclusive<Self>
const PROTOCOL_ASSIGNMENTS_RANGE: RangeInclusive<Self>
The range of primitive address values reserved for IETF protocol assignments for this address family.
sourceconst DOCUMENTATION_RANGES: &'static [RangeInclusive<Self>]
const DOCUMENTATION_RANGES: &'static [RangeInclusive<Self>]
The range of primitive address values defined for “documentation” use for this address family.
sourceconst PRIVATE_RANGES: Option<&'static [RangeInclusive<Self>]>
const PRIVATE_RANGES: Option<&'static [RangeInclusive<Self>]>
The range of primitive address values defined for “private” use, if that is defined for this address family.
sourceconst RESERVED_RANGE: Option<RangeInclusive<Self>>
const RESERVED_RANGE: Option<RangeInclusive<Self>>
The range of primitive address values reserved for future use, if that is defined for this address family.
sourceconst SHARED_RANGE: Option<RangeInclusive<Self>>
const SHARED_RANGE: Option<RangeInclusive<Self>>
The range of primitive address values reserved for “shared” use, if that is defined for this address family.
sourceconst THISNET_RANGE: Option<RangeInclusive<Self>>
const THISNET_RANGE: Option<RangeInclusive<Self>>
The range of primitive address values having “this network” semantics, if that is defined for this address family.
sourceconst ULA_RANGE: Option<RangeInclusive<Self>>
const ULA_RANGE: Option<RangeInclusive<Self>>
The range of primitive address values defined as “unique local addresses”, if that is defined for this address family.
Provided Associated Constants§
sourceconst MIN_LENGTH: Self::Length = <Self::Length>::ZERO
const MIN_LENGTH: Self::Length = <Self::Length>::ZERO
Minimum valid value of the underlying primitive value used to store prefix-lengths for this address-family.
Required Methods§
sourcefn leading_zeros(self) -> Self::Length
fn leading_zeros(self) -> Self::Length
Get the number of leading zeros in the binary representation of self.
sourcefn to_be_bytes(self) -> A::Octets
fn to_be_bytes(self) -> A::Octets
Convert self to big-endian A::Octets.
sourcefn from_be_bytes(bytes: A::Octets) -> Self
fn from_be_bytes(bytes: A::Octets) -> Self
Construct Self from big-endian A::Octets.
sourcefn is_global(&self) -> bool
fn is_global(&self) -> bool
Returns true if this primitive value represents a “globally
routable” address, according to the address family semantics.
sourcefn parse_addr<S>(s: &S) -> Result<Self, Error>where
S: AsRef<str> + ?Sized,
fn parse_addr<S>(s: &S) -> Result<Self, Error>where S: AsRef<str> + ?Sized,
Parse a string into Self.
This method is primarily intended for use via the
FromStr implementation for
Address<A>.
Errors
Fails if the string does not conform to the textual address
representation rules for A.
sourcefn parse_range<S>(
s: &S
) -> Result<(Self, Self::Length, Self::Length, Self::Length), Error>where
S: AsRef<str> + ?Sized,
fn parse_range<S>( s: &S ) -> Result<(Self, Self::Length, Self::Length, Self::Length), Error>where S: AsRef<str> + ?Sized,
Parse a string into a (Self, Self::Length>, Self::Length, Self::Length) quad.
This method is primarily intended for use via the
FromStr implementation for
PrefixRange<A>.
Errors
Fails if the string does not conform to the textual prefix
representation rules for A.