pub enum NetAddress {
IPv4 {
addr: [u8; 4],
port: u16,
},
IPv6 {
addr: [u8; 16],
port: u16,
},
OnionV2([u8; 12]),
OnionV3 {
ed25519_pubkey: [u8; 32],
checksum: u16,
version: u8,
port: u16,
},
}
Expand description
An address which can be used to connect to a remote peer
Variants
IPv4
An IPv4 address/port on which the peer is listening.
IPv6
An IPv6 address/port on which the peer is listening.
OnionV2([u8; 12])
An old-style Tor onion address/port on which the peer is listening.
This field is deprecated and the Tor network generally no longer supports V2 Onion addresses. Thus, the details are not parsed here.
OnionV3
Fields
checksum: u16
The checksum of the pubkey and version, as included in the onion address
version: u8
The version byte, as defined by the Tor Onion v3 spec.
port: u16
The port on which the node is listening
A new-style Tor onion address/port on which the peer is listening. To create the human-readable “hostname”, concatenate ed25519_pubkey, checksum, and version, wrap as base32 and append “.onion”.
Trait Implementations
sourceimpl Clone for NetAddress
impl Clone for NetAddress
sourcefn clone(&self) -> NetAddress
fn clone(&self) -> NetAddress
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for NetAddress
impl Debug for NetAddress
sourceimpl PartialEq<NetAddress> for NetAddress
impl PartialEq<NetAddress> for NetAddress
sourcefn eq(&self, other: &NetAddress) -> bool
fn eq(&self, other: &NetAddress) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &NetAddress) -> bool
fn ne(&self, other: &NetAddress) -> bool
This method tests for !=
.
sourceimpl Readable for NetAddress
impl Readable for NetAddress
sourcefn read<R: Read>(reader: &mut R) -> Result<NetAddress, DecodeError>
fn read<R: Read>(reader: &mut R) -> Result<NetAddress, DecodeError>
Reads a Self in from the given Read
sourceimpl Writeable for NetAddress
impl Writeable for NetAddress
sourcefn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>
Writes self out to the given Writer
sourcefn encode(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn encode(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Writes self out to a Vec
sourcefn encode_with_len(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn encode_with_len(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Writes self out to a Vec
sourcefn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length. Read more
impl StructuralPartialEq for NetAddress
Auto Trait Implementations
impl RefUnwindSafe for NetAddress
impl Send for NetAddress
impl Sync for NetAddress
impl Unpin for NetAddress
impl UnwindSafe for NetAddress
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> MaybeReadable for T where
T: Readable,
impl<T> MaybeReadable for T where
T: Readable,
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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more