Trait net_types::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>)

Object Safety§

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 + LinkLocalAddress> Witness<A> for MulticastAddr<LinkLocalAddr<A>>

source§

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

source§

impl<A: MulticastAddress> Witness<A> for MulticastAddr<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>