Trait strict_encoding::net::Uniform [−][src]
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
fn addr_format(&self) -> AddrFormat
fn addr_format(&self) -> AddrFormat
Should return which address format have to be used for address encoding
Should return transport protocol identifier, if applicable – or None
otherwise
fn from_uniform_addr(addr: UniformAddr) -> Result<Self, DecodeError> where
Self: Sized,
fn from_uniform_addr(addr: UniformAddr) -> Result<Self, DecodeError> where
Self: Sized,
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
.
fn from_uniform_addr_lossy(addr: UniformAddr) -> Result<Self, DecodeError> where
Self: Sized,
fn from_uniform_addr_lossy(addr: UniformAddr) -> Result<Self, DecodeError> where
Self: Sized,
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
fn to_uniform_addr(&self) -> UniformAddr
fn to_uniform_addr(&self) -> UniformAddr
Transforms given address type into a structured uniform address
(see UniformAddr
)
fn to_raw_uniform(&self) -> RawUniformAddr
fn to_raw_uniform(&self) -> RawUniformAddr
Produces unniformally-encoded byte representation of the address
(see RawUniformAddr
).
fn from_raw_uniform_addr(uniform: RawUniformAddr) -> Result<Self, DecodeError> where
Self: Sized,
fn from_raw_uniform_addr(uniform: RawUniformAddr) -> Result<Self, DecodeError> where
Self: Sized,
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
.
fn from_raw_uniform_addr_lossy(
uniform: RawUniformAddr
) -> Result<Self, DecodeError> where
Self: Sized,
fn from_raw_uniform_addr_lossy(
uniform: RawUniformAddr
) -> Result<Self, DecodeError> where
Self: Sized,
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
.