Expand description
A universal address covering IPv4, IPv6 and Tor in a single byte sequence of 32 bytes.
Holds either:
- IPv4-to-IPv6 address
- IPv6 address
- Tor Onion address (V3 only)
NB: we are using [TorPublicKeyV3
] instead of OnionAddressV3
, since
OnionAddressV3
keeps checksum and other information which can be
reconstructed from [TorPublicKeyV3
]. The 2-byte checksum in
OnionAddressV3
is designed for human-readable part that checks that the
address was typed in correctly. In computer-stored digital data it may be
deterministically regenerated and does not add any additional security.
Tor addresses are distinguished by the fact that last 16 bits must be set to 0
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
IPv4(Ipv4Addr)
IP address of V4 standard
IPv6(Ipv6Addr)
IP address of V6 standard
Tor(TorPublicKeyV3)
Tor address of V3 standard
Implementations
sourceimpl InetAddr
impl InetAddr
sourcepub fn to_ipv6(&self) -> Option<Ipv6Addr>
pub fn to_ipv6(&self) -> Option<Ipv6Addr>
Returns an IPv6 address, constructed from IPv4 data; or, if Onion
address is used, Option::None
sourcepub fn to_ipv4(&self) -> Option<Ipv6Addr>
pub fn to_ipv4(&self) -> Option<Ipv6Addr>
Returns an IPv4 address, if any, or Option::None
sourcepub fn to_onion(&self) -> Option<OnionAddressV3>
pub fn to_onion(&self) -> Option<OnionAddressV3>
Returns Onion v3 address, if any, or Option::None
Trait Implementations
sourceimpl Ord for InetAddr
impl Ord for InetAddr
sourceimpl PartialOrd<InetAddr> for InetAddr
impl PartialOrd<InetAddr> for InetAddr
sourcefn partial_cmp(&self, other: &InetAddr) -> Option<Ordering>
fn partial_cmp(&self, other: &InetAddr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Strategy for InetAddr
impl Strategy for InetAddr
type Strategy = UsingUniformAddr
type Strategy = UsingUniformAddr
Specific strategy. List of supported strategies: Read more
sourceimpl Uniform for InetAddr
impl Uniform for InetAddr
sourcefn addr_format(&self) -> AddrFormat
fn addr_format(&self) -> AddrFormat
Should return which address format have to be used for address encoding
sourcefn transport(&self) -> Option<Transport>
fn transport(&self) -> Option<Transport>
Should return transport protocol identifier, if applicable – or None
otherwise Read more
sourcefn from_uniform_addr(addr: UniformAddr) -> Result<InetAddr, DecodeError> where
InetAddr: Sized,
fn from_uniform_addr(addr: UniformAddr) -> Result<InetAddr, DecodeError> where
InetAddr: Sized,
Constructs address of a given type from a structure uniform address data. Read more
sourcefn from_uniform_addr_lossy(addr: UniformAddr) -> Result<InetAddr, DecodeError> where
InetAddr: Sized,
fn from_uniform_addr_lossy(addr: UniformAddr) -> Result<InetAddr, DecodeError> where
InetAddr: Sized,
Constructs address of a given type from a structured uniform address data. Read more
sourcefn to_uniform_addr(&self) -> UniformAddr
fn to_uniform_addr(&self) -> UniformAddr
Transforms given address type into a structured uniform address
(see UniformAddr
) Read more
sourcefn to_raw_uniform(&self) -> [u8; 37]
fn to_raw_uniform(&self) -> [u8; 37]
Produces unniformally-encoded byte representation of the address
(see RawUniformAddr
). Read more
sourcefn from_raw_uniform_addr(uniform: [u8; 37]) -> Result<Self, DecodeError>
fn from_raw_uniform_addr(uniform: [u8; 37]) -> Result<Self, DecodeError>
Constructs address of a given type from a uniformly-encoded byte string
(see RawUniformAddr
). Read more
sourcefn from_raw_uniform_addr_lossy(uniform: [u8; 37]) -> Result<Self, DecodeError>
fn from_raw_uniform_addr_lossy(uniform: [u8; 37]) -> Result<Self, DecodeError>
Constructs address of a given type from a uniformly-encoded byte string
(see RawUniformAddr
). Read more
impl Copy for InetAddr
impl Eq for InetAddr
impl StructuralEq for InetAddr
impl StructuralPartialEq for InetAddr
Auto Trait Implementations
impl RefUnwindSafe for InetAddr
impl Send for InetAddr
impl Sync for InetAddr
impl Unpin for InetAddr
impl UnwindSafe for InetAddr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more