Enum NetAddr
pub enum NetAddr {
Inet(IpAddr, u16),
Name(Cow<'static, str>, u16),
}Expand description
A network address.
Either an IP address and port number or else a hostname and port number.
Variants§
Implementations§
§impl NetAddr
impl NetAddr
pub fn named<S>(name: S, port: u16) -> NetAddr
pub fn with_port(self, p: u16) -> NetAddr
pub fn with_offset(self, o: u16) -> NetAddr
pub fn is_ip(&self) -> bool
pub fn is_probably_global(&self) -> bool
pub fn is_probably_global(&self) -> bool
Whether this address is plausibly publicly routable. Returns false for IP literals
in non-globally-routable ranges (loopback, unspecified, RFC 1918 private, link-local,
broadcast, documentation, IPv6 multicast) and the literal localhost. Other hostnames
are trusted and return true. Approximates the (still unstable) IpAddr::is_global
using stable predicates; the IPv6 surface is incomplete (fe80::/10 link-local and
fc00::/7 unique-local addresses are treated as global here).
Trait Implementations§
§impl<'de> Deserialize<'de> for NetAddr
Available on crate feature serde only.
impl<'de> Deserialize<'de> for NetAddr
Available on crate feature
serde only.§fn deserialize<D>(d: D) -> Result<NetAddr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<NetAddr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl From<SocketAddr> for NetAddr
impl From<SocketAddr> for NetAddr
§fn from(a: SocketAddr) -> NetAddr
fn from(a: SocketAddr) -> NetAddr
Converts to this type from the input type.
§impl Ord for NetAddr
impl Ord for NetAddr
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
§impl PartialOrd for NetAddr
impl PartialOrd for NetAddr
§impl Serialize for NetAddr
Available on crate feature serde only.
impl Serialize for NetAddr
Available on crate feature
serde only.§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for NetAddr
impl StructuralPartialEq for NetAddr
Auto Trait Implementations§
impl Freeze for NetAddr
impl RefUnwindSafe for NetAddr
impl Send for NetAddr
impl Sync for NetAddr
impl Unpin for NetAddr
impl UnsafeUnpin for NetAddr
impl UnwindSafe for NetAddr
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.