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§
Source§impl NetAddr
impl NetAddr
pub fn named<S>(name: S, port: u16) -> Self
pub fn with_port(self, p: u16) -> Self
pub fn with_offset(self, o: u16) -> Self
pub fn is_ip(&self) -> bool
Sourcepub 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§
Source§impl<'de> Deserialize<'de> for NetAddr
Available on crate feature serde only.
impl<'de> Deserialize<'de> for NetAddr
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<SocketAddr> for NetAddr
impl From<SocketAddr> for NetAddr
Source§fn from(a: SocketAddr) -> Self
fn from(a: SocketAddr) -> Self
Converts to this type from the input type.
Source§impl Ord for NetAddr
impl Ord for NetAddr
Source§impl PartialOrd for NetAddr
impl PartialOrd for NetAddr
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.