net_types

Trait Witness

Source
pub trait Witness<A>:
    AsRef<A>
    + Sized
    + Sealed {
    // Required methods
    fn new(addr: A) -> Option<Self>;
    unsafe fn new_unchecked(addr: A) -> Self;
    fn into_addr(self) -> A;

    // Provided methods
    fn from_witness<W: Witness<A>>(addr: W) -> Option<Self> { ... }
    fn get(&self) -> A
       where A: Copy { ... }
    fn transpose<T>(self) -> A::Map<Self::Map<T>>
       where Self: TransposableWitness<A>,
             A: TransposableWitness<T>,
             Self::Map<T>: Witness<T>,
             A::Map<Self::Map<T>>: Witness<Self::Map<T>> { ... }
}
Expand description

A type which is a witness to some property about an address.

A type which implements Witness<A> wraps an address of type A and guarantees some property about the wrapped address. It is implemented by SpecifiedAddr, UnicastAddr, MulticastAddr, LinkLocalAddr, and NonMappedAddr.

Required Methods§

Source

fn new(addr: A) -> Option<Self>

Constructs a new witness type.

new returns None if addr does not satisfy the property guaranteed by Self.

Source

unsafe fn new_unchecked(addr: A) -> Self

Constructs a new witness type without checking to see if addr actually satisfies the required property.

§Safety

It is up to the caller to make sure that addr satisfies the required property in order to avoid breaking the guarantees of this trait.

Source

fn into_addr(self) -> A

Consumes this witness and returns the contained A.

If A: Copy, prefer get instead of into_addr. get is idiomatic for wrapper types which which wrap Copy types (e.g., see NonZeroUsize::get or Cell::get). into_xxx methods are idiomatic only when self must be consumed by value because the wrapped value is not Copy (e.g., see Cell::into_inner).

Provided Methods§

Source

fn from_witness<W: Witness<A>>(addr: W) -> Option<Self>

Constructs a new witness type from an existing witness type.

from_witness(witness) is equivalent to new(witness.into_addr()).

Source

fn get(&self) -> A
where A: Copy,

Gets a copy of the address.

Source

fn transpose<T>(self) -> A::Map<Self::Map<T>>
where Self: TransposableWitness<A>, A: TransposableWitness<T>, Self::Map<T>: Witness<T>, A::Map<Self::Map<T>>: Witness<Self::Map<T>>,

Transposes this witness type with another witness type layered inside of it. (e.g. UnicastAddr<SpecifiedAddr> -> SpecifiedAddr<UnicastAddr>)

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.

Implementors§

Source§

impl Witness<Ipv6Addr> for Ipv6SourceAddr

Source§

impl Witness<Ipv6Addr> for UnicastOrMulticastIpv6Addr

Source§

impl<A: BroadcastAddress + LinkLocalAddress> Witness<A> for BroadcastAddr<LinkLocalAddr<A>>

Source§

impl<A: BroadcastAddress + MappedAddress> Witness<A> for BroadcastAddr<NonMappedAddr<A>>

Source§

impl<A: BroadcastAddress> Witness<A> for BroadcastAddr<A>

Source§

impl<A: LinkLocalAddress + BroadcastAddress> Witness<A> for LinkLocalAddr<BroadcastAddr<A>>

Source§

impl<A: LinkLocalAddress + MappedAddress> Witness<A> for LinkLocalAddr<NonMappedAddr<A>>

Source§

impl<A: LinkLocalAddress + MulticastAddress> Witness<A> for LinkLocalAddr<MulticastAddr<A>>

Source§

impl<A: LinkLocalAddress + UnicastAddress> Witness<A> for LinkLocalAddr<UnicastAddr<A>>

Source§

impl<A: LinkLocalAddress> Witness<A> for LinkLocalAddr<A>

Source§

impl<A: MappedAddress + BroadcastAddress> Witness<A> for NonMappedAddr<BroadcastAddr<A>>

Source§

impl<A: MappedAddress + LinkLocalAddress> Witness<A> for NonMappedAddr<LinkLocalAddr<A>>

Source§

impl<A: MappedAddress + MulticastAddress> Witness<A> for NonMappedAddr<MulticastAddr<A>>

Source§

impl<A: MappedAddress + SpecifiedAddress> Witness<A> for NonMappedAddr<SpecifiedAddr<A>>

Source§

impl<A: MappedAddress + UnicastAddress> Witness<A> for NonMappedAddr<UnicastAddr<A>>

Source§

impl<A: MappedAddress> Witness<A> for NonMappedAddr<A>

Source§

impl<A: MulticastAddress + BroadcastAddress> Witness<A> for NonMulticastAddr<BroadcastAddr<A>>

Source§

impl<A: MulticastAddress + LinkLocalAddress> Witness<A> for MulticastAddr<LinkLocalAddr<A>>

Source§

impl<A: MulticastAddress + MappedAddress + SpecifiedAddress> Witness<A> for NonMulticastAddr<NonMappedAddr<SpecifiedAddr<A>>>

Source§

impl<A: MulticastAddress + MappedAddress> Witness<A> for MulticastAddr<NonMappedAddr<A>>

Source§

impl<A: MulticastAddress + MappedAddress> Witness<A> for NonMulticastAddr<NonMappedAddr<A>>

Source§

impl<A: MulticastAddress + SpecifiedAddress> Witness<A> for NonMulticastAddr<SpecifiedAddr<A>>

Source§

impl<A: MulticastAddress + UnicastAddress> Witness<A> for NonMulticastAddr<UnicastAddr<A>>

Source§

impl<A: MulticastAddress> Witness<A> for MulticastAddr<A>

Source§

impl<A: MulticastAddress> Witness<A> for NonMulticastAddr<A>

Source§

impl<A: SpecifiedAddress> Witness<A> for SpecifiedAddr<A>

Source§

impl<A: UnicastAddress + LinkLocalAddress> Witness<A> for UnicastAddr<LinkLocalAddr<A>>

Source§

impl<A: UnicastAddress + MappedAddress> Witness<A> for UnicastAddr<NonMappedAddr<A>>

Source§

impl<A: UnicastAddress> Witness<A> for UnicastAddr<A>