pub struct NetworkAddress {
pub socket_addr: SocketAddr,
pub four_words: Option<String>,
}Expand description
Network address that can be represented as IP:port or four-word format
Fields§
§socket_addr: SocketAddrThe socket address (IP + port)
four_words: Option<String>Optional four-word representation
Implementations§
Source§impl NetworkAddress
impl NetworkAddress
Sourcepub fn new(socket_addr: SocketAddr) -> Self
pub fn new(socket_addr: SocketAddr) -> Self
Create a new NetworkAddress from a SocketAddr
Sourcepub fn from_ip_port(ip: IpAddr, port: u16) -> Self
pub fn from_ip_port(ip: IpAddr, port: u16) -> Self
Create a NetworkAddress from an IP address and port
Sourcepub fn from_ipv4(ip: Ipv4Addr, port: u16) -> Self
pub fn from_ipv4(ip: Ipv4Addr, port: u16) -> Self
Create a NetworkAddress from IPv4 address and port
Sourcepub fn from_ipv6(ip: Ipv6Addr, port: u16) -> Self
pub fn from_ipv6(ip: Ipv6Addr, port: u16) -> Self
Create a NetworkAddress from IPv6 address and port
Sourcepub fn socket_addr(&self) -> SocketAddr
pub fn socket_addr(&self) -> SocketAddr
Get the socket address
Sourcepub fn four_words(&self) -> Option<&str>
pub fn four_words(&self) -> Option<&str>
Get the four-word representation if available
Sourcepub fn regenerate_four_words(&mut self)
pub fn regenerate_four_words(&mut self)
Force regeneration of four-word representation
Sourcepub fn from_four_words(words: &str) -> Result<Self>
pub fn from_four_words(words: &str) -> Result<Self>
Decode four-word format to NetworkAddress using four-word-networking
Sourcepub fn is_loopback(&self) -> bool
pub fn is_loopback(&self) -> bool
Check if this is a loopback address
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Check if this is a private/local address
Trait Implementations§
Source§impl Clone for NetworkAddress
impl Clone for NetworkAddress
Source§fn clone(&self) -> NetworkAddress
fn clone(&self) -> NetworkAddress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkAddress
impl Debug for NetworkAddress
Source§impl<'de> Deserialize<'de> for NetworkAddress
impl<'de> Deserialize<'de> for NetworkAddress
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for NetworkAddress
impl Display for NetworkAddress
Source§impl From<&NetworkAddress> for SocketAddr
impl From<&NetworkAddress> for SocketAddr
Source§fn from(addr: &NetworkAddress) -> Self
fn from(addr: &NetworkAddress) -> Self
Converts to this type from the input type.
Source§impl From<&SocketAddr> for NetworkAddress
impl From<&SocketAddr> for NetworkAddress
Source§fn from(socket_addr: &SocketAddr) -> Self
fn from(socket_addr: &SocketAddr) -> Self
Converts to this type from the input type.
Source§impl From<NetworkAddress> for SocketAddr
impl From<NetworkAddress> for SocketAddr
Source§fn from(addr: NetworkAddress) -> Self
fn from(addr: NetworkAddress) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddr> for NetworkAddress
impl From<SocketAddr> for NetworkAddress
Source§fn from(socket_addr: SocketAddr) -> Self
fn from(socket_addr: SocketAddr) -> Self
Converts to this type from the input type.
Source§impl FromStr for NetworkAddress
impl FromStr for NetworkAddress
Source§impl Hash for NetworkAddress
impl Hash for NetworkAddress
Source§impl PartialEq for NetworkAddress
impl PartialEq for NetworkAddress
Source§impl Serialize for NetworkAddress
impl Serialize for NetworkAddress
impl Eq for NetworkAddress
impl StructuralPartialEq for NetworkAddress
Auto Trait Implementations§
impl Freeze for NetworkAddress
impl RefUnwindSafe for NetworkAddress
impl Send for NetworkAddress
impl Sync for NetworkAddress
impl Unpin for NetworkAddress
impl UnsafeUnpin for NetworkAddress
impl UnwindSafe for NetworkAddress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.