pub enum Addr {
SocketAddr(SocketAddr),
Unix(Arc<SocketAddr>),
Custom(&'static str, Cow<'static, str>),
}
Expand description
An network address.
Variants
SocketAddr(SocketAddr)
Internet socket address
Unix(Arc<SocketAddr>)
Available on Unix only.
Unix domain socket address
Custom(&'static str, Cow<'static, str>)
Custom address
Implementations
sourceimpl Addr
impl Addr
sourcepub fn socket(addr: SocketAddr) -> Self
pub fn socket(addr: SocketAddr) -> Self
Create a internet socket address.
sourcepub fn unix(addr: SocketAddr) -> Self
Available on Unix only.
pub fn unix(addr: SocketAddr) -> Self
Create a unix socket address.
sourcepub fn custom(scheme: &'static str, addr: impl Into<Cow<'static, str>>) -> Self
pub fn custom(scheme: &'static str, addr: impl Into<Cow<'static, str>>) -> Self
Create a custom address.
sourcepub fn as_socket_addr(&self) -> Option<&SocketAddr>
pub fn as_socket_addr(&self) -> Option<&SocketAddr>
If the address is a internet socket address, returns it. Returns None otherwise.
sourcepub fn as_unix_socket_addr(&self) -> Option<&SocketAddr>
Available on Unix only.
pub fn as_unix_socket_addr(&self) -> Option<&SocketAddr>
If the address is a unix socket address, returns it. Returns None otherwise.
Trait Implementations
sourceimpl From<SocketAddr> for Addr
impl From<SocketAddr> for Addr
sourcefn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
sourceimpl From<SocketAddr> for Addr
impl From<SocketAddr> for Addr
sourcefn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for Addr
impl Send for Addr
impl Sync for Addr
impl Unpin for Addr
impl UnwindSafe for Addr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more