[][src]Enum internet2::addr::InetAddr

#[non_exhaustive]pub enum InetAddr {
    IPv4(Ipv4Addr),
    IPv6(Ipv6Addr),
    TorV2(OnionAddressV2),
    Tor(TorPublicKeyV3),
}

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)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
IPv4(Ipv4Addr)

IP address of V4 standard

IPv6(Ipv6Addr)

IP address of V6 standard

TorV2(OnionAddressV2)

Tor address of V3 standard

Tor(TorPublicKeyV3)

Tor address of V2 standard

Implementations

impl InetAddr[src]

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

pub fn to_onion_v2(&self) -> Option<OnionAddressV2>[src]

Returns Onion v2 address, if any, or Option::None

pub fn to_onion(&self) -> Option<OnionAddressV3>[src]

Returns Onion v3 address, if any, or Option::None

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 From<OnionAddressV2> for InetAddr[src]

impl From<OnionAddressV3> for InetAddr[src]

impl From<TorPublicKeyV3> for InetAddr[src]

impl FromStr for InetAddr[src]

type Err = AddrParseError

The associated error which can be returned from parsing.

impl Hash for InetAddr[src]

impl Ord for InetAddr[src]

impl ParseArgFromStr for InetAddr[src]

impl PartialEq<InetAddr> for InetAddr[src]

impl PartialOrd<InetAddr> for InetAddr[src]

impl Strategy for InetAddr[src]

impl Strategy for InetAddr[src]

impl StructuralEq for InetAddr[src]

impl StructuralPartialEq for InetAddr[src]

impl<'_> TryFrom<&'_ str> for InetAddr[src]

type Error = <InetAddr as FromStr>::Err

The type returned in the event of a conversion error.

impl Uniform for InetAddr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,