pub trait Uniform {
    fn addr_format(&self) -> AddrFormat;
    fn addr(&self) -> RawAddr;
    fn port(&self) -> Option<u16>;
    fn transport(&self) -> Option<Transport>;
    fn from_uniform_addr(addr: UniformAddr) -> Result<Self, DecodeError>
    where
        Self: Sized
; fn from_uniform_addr_lossy(addr: UniformAddr) -> Result<Self, DecodeError>
    where
        Self: Sized
; fn to_uniform_addr(&self) -> UniformAddr { ... } fn to_raw_uniform(&self) -> RawUniformAddr { ... } fn from_raw_uniform_addr(
        uniform: RawUniformAddr
    ) -> Result<Self, DecodeError>
    where
        Self: Sized
, { ... } fn from_raw_uniform_addr_lossy(
        uniform: RawUniformAddr
    ) -> Result<Self, DecodeError>
    where
        Self: Sized
, { ... } }
Expand description

Uniform encoding trait, which should be implemented by different address structures which allow representation as UniformAddr and encoding to RawUniformAddr.

Required Methods§

Should return which address format have to be used for address encoding

Should return uniformly-encoded host address

Should return port number, if present – or None otherwise

Should return transport protocol identifier, if applicable – or None otherwise

Constructs address of a given type from a structure uniform address data.

If the uniform data contain more information than can be fit into current address representation (for instance port number or transport protocol can’t fit IpAddr) the function will ignore this information. If this is not desirable, pls use Uniform::from_uniform_addr_lossy.

Constructs address of a given type from a structured uniform address data.

If the uniform data contain more information than can be fit into current address representation (for instance port number or transport protocol can’t fit IpAddr) the function fail with DecodeError::ExcessiveData. If this is not desirable, pls use Uniform::from_uniform_addr.

Provided Methods§

Transforms given address type into a structured uniform address (see UniformAddr)

Produces unniformally-encoded byte representation of the address (see RawUniformAddr).

Constructs address of a given type from a uniformly-encoded byte string (see RawUniformAddr).

If the uniform data contain more information than can be fit into current address representation (for instance port number or transport protocol can’t fit IpAddr) the function will ignore this information. If this is not desirable, pls use Uniform::from_raw_uniform_addr_lossy.

Constructs address of a given type from a uniformly-encoded byte string (see RawUniformAddr).

If the uniform data contain more information than can be fit into current address representation (for instance port number or transport protocol can’t fit IpAddr) the function fail with DecodeError::ExcessiveData. If this is not desirable, pls use Uniform::from_raw_uniform_addr.

Implementations on Foreign Types§

Implementors§