Trait ip::traits::primitive::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 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§

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 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 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_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.

Implementations on Foreign Types§

source§

impl Address<Ipv6> for u128

§

type Length = u8

§

type LengthMap = BitArray<[usize; 5], Lsb0>

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§

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_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<Ipv4> for u32

§

type Length = u8

§

type LengthMap = BitArray<[usize; 2], Lsb0>

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§

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_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§