Enum inet2_addr::InetAddr
source · [−]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
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 is_tor(&self) -> bool
pub fn is_tor(&self) -> bool
Determines whether provided address is a Tor address. Always returns
fales
(the library is built without tor
feature; use it to
enable Tor addresses).
sourcepub fn to_onion_v2(&self) -> Option<()>
pub fn to_onion_v2(&self) -> Option<()>
Always returns Option::None
(the library is built without tor
feature; use it to enable Tor addresses).
sourcepub fn to_onion(&self) -> Option<()>
pub fn to_onion(&self) -> Option<()>
Always returns Option::None
(the library is built without tor
feature; use it to enable Tor addresses).
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: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> 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
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more