Enum inet2_addr::InetAddr
source · #[non_exhaustive]
pub enum InetAddr {
IPv4(Ipv4Addr),
IPv6(Ipv6Addr),
}
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.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
source§impl InetAddr
impl InetAddr
sourcepub fn ipv6_addr(self) -> Option<Ipv6Addr>
pub fn ipv6_addr(self) -> Option<Ipv6Addr>
Returns an IPv6 address, constructed from IPv4 data; or, if Onion
address is used, Option::None
sourcepub fn ipv4_addr(self) -> Option<Ipv4Addr>
pub fn ipv4_addr(self) -> Option<Ipv4Addr>
Returns an IPv4 address, if any, or Option::None
sourcepub fn is_tor(self) -> bool
pub fn is_tor(self) -> bool
Determines whether provided address is a Tor address. Always returns
false
(the library is built without tor
feature; use it to
enable Tor addresses).
sourcepub fn onion_address(self) -> Option<()>
pub fn onion_address(self) -> Option<()>
Always returns Option::None
(the library is built without tor
feature; use it to enable Tor addresses).
Trait Implementations§
source§impl From<InetAddr> for PartialSocketAddr
impl From<InetAddr> for PartialSocketAddr
source§impl Ord for InetAddr
impl Ord for InetAddr
source§impl PartialEq<InetAddr> for InetAddr
impl PartialEq<InetAddr> for InetAddr
source§impl PartialOrd<InetAddr> for InetAddr
impl PartialOrd<InetAddr> for InetAddr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more