pub struct NetAddr {
pub host: String,
pub port: u16,
}Fields§
§host: String§port: u16Implementations§
Source§impl NetAddr
impl NetAddr
pub const LOCALHOST: &'static str = "0.0.0.0"
pub const DEFAULT_HOST: &'static str = "0.0.0.0"
pub const DEFAULT_PORT: u16 = 8_080u16
Sourcepub fn new<H>(host: H, port: u16) -> Selfwhere
H: ToString,
pub fn new<H>(host: H, port: u16) -> Selfwhere
H: ToString,
initialize a new instance of the network address from the given components
pub fn from_ip_with_port(ip: IpAddr, port: u16) -> Self
Sourcepub fn from_socket_addr(addr: SocketAddr) -> Self
pub fn from_socket_addr(addr: SocketAddr) -> Self
convert the given socket address into a valid network address
Sourcepub fn localhost(port: u16) -> Self
pub fn localhost(port: u16) -> Self
initialize a new instance of the network address bound to localhost and the given port
Sourcepub fn as_socket_addr(&self) -> SocketAddr
pub fn as_socket_addr(&self) -> SocketAddr
convert a reference of the network address into a SocketAddr
Sourcepub async fn bind(&self) -> Result<TcpListener>
pub async fn bind(&self) -> Result<TcpListener>
initialize a new listener, bound to the configured address
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NetAddr
impl<'de> Deserialize<'de> for NetAddr
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 From<SocketAddr> for NetAddr
impl From<SocketAddr> for NetAddr
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: 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 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