[−][src]Enum inet2_addr::InetAddr
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 address (V2 and V3)
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.
For Version2 Tor support only OnionAddressV2
handling is supported.
OnionAddressV2
can only be constructed from an address string.
Tor addresses are distinguished by the fact that last 16 bits must be set to 0
Variants (Non-exhaustive)
IPv4(Ipv4Addr)
IP address of V4 standard
IPv6(Ipv6Addr)
IP address of V6 standard
Implementations
impl InetAddr
[src]
pub const UNIFORM_ADDR_LEN: usize
[src]
Length of the encoded address; equal to the maximal length of encoding for different address types
pub fn to_ipv6(&self) -> Option<Ipv6Addr>
[src]
Returns an IPv6 address, constructed from IPv4 data; or, if Onion
address is used, Option::None
pub fn to_ipv4(&self) -> Option<Ipv6Addr>
[src]
Returns an IPv4 address, if any, or Option::None
pub fn is_tor(&self) -> bool
[src]
Determines whether provided address is a Tor address. Always returns
fales
(the library is built without tor
feature; use it to
enable Tor addresses).
pub fn to_onion_v2(&self) -> Option<()>
[src]
Always returns Option::None
(the library is built without tor
feature; use it to enable Tor addresses).
pub fn to_onion(&self) -> Option<()>
[src]
Always returns Option::None
(the library is built without tor
feature; use it to enable Tor addresses).
pub fn from_uniform_encoding(data: &[u8]) -> Option<Self>
[src]
Decodes byte array containing uniform encoding of some internet address,
constructed with [to_uniform_encoding()
]. If the address can't be
recognized, returns Option::None
pub fn to_uniform_encoding(&self) -> [u8; 33]
[src]
Encodes address into a uniform byte array for storage. Here, uniform
means that it can contain any possible internet address and have some
fixed length (equal to InetAddr::UNIFORM_ADDR_LEN
)
Trait Implementations
impl Clone for InetAddr
[src]
impl Copy for InetAddr
[src]
impl Debug for InetAddr
[src]
impl Default for InetAddr
[src]
impl Display for InetAddr
[src]
impl Eq for InetAddr
[src]
impl From<[u16; 8]> for InetAddr
[src]
impl From<[u8; 16]> for InetAddr
[src]
impl From<[u8; 4]> for InetAddr
[src]
impl From<IpAddr> for InetAddr
[src]
impl From<Ipv4Addr> for InetAddr
[src]
impl From<Ipv6Addr> for InetAddr
[src]
impl FromStr for InetAddr
[src]
type Err = AddrParseError
The associated error which can be returned from parsing.
pub fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for InetAddr
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for InetAddr
[src]
pub fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<InetAddr> for InetAddr
[src]
impl PartialOrd<InetAddr> for InetAddr
[src]
pub fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for InetAddr
[src]
impl StructuralPartialEq for InetAddr
[src]
impl TryFrom<&'_ [u8]> for InetAddr
[src]
type Error = UniformEncodingError
The type returned in the event of a conversion error.
pub fn try_from(value: &[u8]) -> Result<Self, Self::Error>
[src]
impl TryFrom<&'_ str> for InetAddr
[src]
type Error = <InetAddr as FromStr>::Err
The type returned in the event of a conversion error.
pub fn try_from(value: &str) -> Result<Self, Self::Error>
[src]
impl TryFrom<Vec<u8, Global>> for InetAddr
[src]
Auto Trait Implementations
impl RefUnwindSafe for InetAddr
[src]
impl Send for InetAddr
[src]
impl Sync for InetAddr
[src]
impl Unpin for InetAddr
[src]
impl UnwindSafe for InetAddr
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,