Trait Address

Source
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 8 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_length<S>(s: &S) -> Result<Self::Length, 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 Constants§

Source

const MAX_LENGTH: Self::Length

Maximum valid value of the underlying primitive value used to store prefix-lengths for this address-family.

Source

const ZERO: Self

“All-zeros” IP address representation.

Source

const ONES: Self

“All-ones” IP address representation.

Source

const BROADCAST: Option<Self>

The primitive value of the subnet-local broadcast address, if it is defined for the address family.

Source

const LOCALHOST: Self

The primitive value of the localhost address for this address family.

Source

const UNSPECIFIED: Self

The primitive value of the “unspecified” address for this address family.

Source

const LOOPBACK_RANGE: RangeInclusive<Self>

The range of primitive address values defined for “loopback” use for this address family.

Source

const BENCHMARK_RANGE: RangeInclusive<Self>

The range of primitive address values defined for “benchmarking” use for this address family.

Source

const MULTICAST_RANGE: RangeInclusive<Self>

The range of primitive address values defined for “multicast” use for this address family.

The range of primitive address values defined for “link-local” use for this address family.

Source

const PROTOCOL_ASSIGNMENTS_RANGE: RangeInclusive<Self>

The range of primitive address values reserved for IETF protocol assignments for this address family.

Source

const DOCUMENTATION_RANGES: &'static [RangeInclusive<Self>]

The range of primitive address values defined for “documentation” use for this address family.

Source

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.

Source

const RESERVED_RANGE: Option<RangeInclusive<Self>>

The range of primitive address values reserved for future use, if that is defined for this address family.

Source

const SHARED_RANGE: Option<RangeInclusive<Self>>

The range of primitive address values reserved for “shared” use, if that is defined for this address family.

Source

const THISNET_RANGE: Option<RangeInclusive<Self>>

The range of primitive address values having “this network” semantics, if that is defined for this address family.

Source

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§

Source

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 Associated Types§

Source

type Length: Length

Underlying primitive type used to store bit-widths of Self.

Source

type LengthMap: LengthMap

Underlying primitive type used to store bitmaps of prefix-lengths.

Required Methods§

Source

fn leading_zeros(self) -> Self::Length

Get the number of leading zeros in the binary representation of self.

Source

fn to_be_bytes(self) -> A::Octets

Convert self to big-endian A::Octets.

Source

fn from_be_bytes(bytes: A::Octets) -> Self

Construct Self from big-endian A::Octets.

Source

fn is_global(&self) -> bool

Returns true if this primitive value represents a “globally routable” address, according to the address family semantics.

Source

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.

Source

fn parse_length<S>(s: &S) -> Result<Self::Length, Error>
where S: AsRef<str> + ?Sized,

Parse a string into Self::Length.

This method is primarily intended for use via the FromStr implementation for PrefixLength<A>.

§Errors

Fails if the string does not conform to the textual address representation rules for A.

Source

fn parse_prefix<S>(s: &S) -> Result<(Self, Self::Length), Error>
where S: AsRef<str> + ?Sized,

Parse a string into a (Self, Self::Length>) pair.

This method is primarily intended for use via the FromStr implementation for Prefix<A>.

§Errors

Fails if the string does not conform to the textual prefix representation rules for A.

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Address<Ipv4> for u32

Source§

const MAX_LENGTH: Self::Length = {transmute(0x20): <u32 as traits::primitive::Address<concrete::af::Ipv4>>::Length}

Source§

const ZERO: Self = 0u32

Source§

const ONES: Self = 4_294_967_295u32

Source§

const BROADCAST: Option<Self>

Source§

const LOCALHOST: Self = 2_130_706_433u32

Source§

const UNSPECIFIED: Self = 0u32

Source§

const LOOPBACK_RANGE: RangeInclusive<Self>

Source§

const BENCHMARK_RANGE: RangeInclusive<Self>

Source§

const MULTICAST_RANGE: RangeInclusive<Self>

Source§

const PROTOCOL_ASSIGNMENTS_RANGE: RangeInclusive<Self>

Source§

const DOCUMENTATION_RANGES: &'static [RangeInclusive<Self>]

Source§

const PRIVATE_RANGES: Option<&'static [RangeInclusive<Self>]>

Source§

const RESERVED_RANGE: Option<RangeInclusive<Self>>

Source§

const SHARED_RANGE: Option<RangeInclusive<Self>>

Source§

const THISNET_RANGE: Option<RangeInclusive<Self>>

Source§

const ULA_RANGE: Option<RangeInclusive<Self>> = None

Source§

type Length = u8

Source§

type LengthMap = BitArray<[usize; 1]>

Source§

fn leading_zeros(self) -> Self::Length

Source§

fn to_be_bytes(self) -> <Ipv4 as Afi>::Octets

Source§

fn from_be_bytes(bytes: <Ipv4 as Afi>::Octets) -> Self

Source§

fn is_global(&self) -> bool

Source§

fn parse_addr<S>(s: &S) -> Result<Self, Error>
where S: AsRef<str> + ?Sized,

Source§

fn parse_length<S>(s: &S) -> Result<Self::Length, Error>
where S: AsRef<str> + ?Sized,

Source§

fn parse_prefix<S>(s: &S) -> Result<(Self, Self::Length), Error>
where S: AsRef<str> + ?Sized,

Source§

fn parse_range<S>( s: &S, ) -> Result<(Self, Self::Length, Self::Length, Self::Length), Error>
where S: AsRef<str> + ?Sized,

Source§

impl Address<Ipv6> for u128

Source§

const MAX_LENGTH: Self::Length = {transmute(0x80): <u128 as traits::primitive::Address<concrete::af::Ipv6>>::Length}

Source§

const ZERO: Self = 0u128

Source§

const ONES: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

const BROADCAST: Option<Self> = None

Source§

const LOCALHOST: Self = 1u128

Source§

const UNSPECIFIED: Self = 0u128

Source§

const LOOPBACK_RANGE: RangeInclusive<Self>

Source§

const BENCHMARK_RANGE: RangeInclusive<Self>

Source§

const MULTICAST_RANGE: RangeInclusive<Self>

Source§

const PROTOCOL_ASSIGNMENTS_RANGE: RangeInclusive<Self>

Source§

const DOCUMENTATION_RANGES: &'static [RangeInclusive<Self>]

Source§

const PRIVATE_RANGES: Option<&'static [RangeInclusive<Self>]> = None

Source§

const RESERVED_RANGE: Option<RangeInclusive<Self>> = None

Source§

const SHARED_RANGE: Option<RangeInclusive<Self>> = None

Source§

const THISNET_RANGE: Option<RangeInclusive<Self>> = None

Source§

const ULA_RANGE: Option<RangeInclusive<Self>>

Source§

type Length = u8

Source§

type LengthMap = BitArray<[usize; 3]>

Source§

fn leading_zeros(self) -> Self::Length

Source§

fn to_be_bytes(self) -> <Ipv6 as Afi>::Octets

Source§

fn from_be_bytes(bytes: <Ipv6 as Afi>::Octets) -> Self

Source§

fn is_global(&self) -> bool

Source§

fn parse_addr<S>(s: &S) -> Result<Self, Error>
where S: AsRef<str> + ?Sized,

Source§

fn parse_length<S>(s: &S) -> Result<Self::Length, Error>
where S: AsRef<str> + ?Sized,

Source§

fn parse_prefix<S>(s: &S) -> Result<(Self, Self::Length), Error>
where S: AsRef<str> + ?Sized,

Source§

fn parse_range<S>( s: &S, ) -> Result<(Self, Self::Length, Self::Length, Self::Length), Error>
where S: AsRef<str> + ?Sized,

Implementors§