Struct systemd_socket::SocketAddr
source · pub struct SocketAddr(/* private fields */);
Expand description
Socket address that can be an ordinary address or a systemd socket
This is the core type of this crate that abstracts possible addresses.
It can be (fallibly) converted from various types of strings or deserialized with serde
.
After it’s created, it can be bound as TcpListener
from std
or even tokio
or async_std
if the appropriate feature is enabled.
Optional dependencies on parse_arg
and serde
make it trivial to use with
configure_me
.
Implementations§
source§impl SocketAddr
impl SocketAddr
sourcepub fn from_systemd_name<T: Into<String>>(name: T) -> Result<Self, ParseError>
pub fn from_systemd_name<T: Into<String>>(name: T) -> Result<Self, ParseError>
Creates SocketAddr from systemd name directly, without requiring systemd://
prefix.
Always fails with systemd unsupported error if systemd is not supported.
sourcepub fn bind(self) -> Result<TcpListener, BindError>
pub fn bind(self) -> Result<TcpListener, BindError>
Creates std::net::TcpListener
This method either binds
the socket, if the address was provided or uses systemd socket
if the socket name was provided.
sourcepub async fn bind_tokio(self) -> Result<TcpListener, TokioBindError>
Available on crate feature tokio
only.
pub async fn bind_tokio(self) -> Result<TcpListener, TokioBindError>
tokio
only.Creates tokio::net::TcpListener
To be specific, it binds the socket or converts systemd socket to tokio
1.0 socket.
This method either binds
the socket, if the address was provided or uses systemd socket
if the socket name was provided.
sourcepub async fn bind_tokio_0_2(self) -> Result<TcpListener, TokioBindError>
Available on crate feature tokio_0_2
only.
pub async fn bind_tokio_0_2(self) -> Result<TcpListener, TokioBindError>
tokio_0_2
only.Creates tokio::net::TcpListener
To be specific, it binds the socket or converts systemd socket to tokio
0.2 socket.
This method either binds
the socket, if the address was provided or uses systemd socket
if the socket name was provided.
sourcepub async fn bind_tokio_0_3(self) -> Result<TcpListener, TokioBindError>
Available on crate feature tokio_0_3
only.
pub async fn bind_tokio_0_3(self) -> Result<TcpListener, TokioBindError>
tokio_0_3
only.Creates tokio::net::TcpListener
To be specific, it binds the socket or converts systemd socket to tokio
0.3 socket.
This method either binds
the socket, if the address was provided or uses systemd socket
if the socket name was provided.
sourcepub async fn bind_async_std(self) -> Result<TcpListener, BindError>
Available on crate feature async-std
only.
pub async fn bind_async_std(self) -> Result<TcpListener, BindError>
async-std
only.Creates async_std::net::TcpListener
To be specific, it binds the socket or converts systemd socket to async_std
socket.
This method either binds
the socket, if the address was provided or uses systemd socket
if the socket name was provided.
Trait Implementations§
source§impl Debug for SocketAddr
impl Debug for SocketAddr
source§impl<'de> Deserialize<'de> for SocketAddr
impl<'de> Deserialize<'de> for SocketAddr
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>,
source§impl Display for SocketAddr
impl Display for SocketAddr
Displays the address in format that can be parsed again.
Important: While I don’t expect this impl to change, don’t rely on it! It should be used mostly for debugging/logging.
source§impl From<SocketAddr> for SocketAddr
impl From<SocketAddr> for SocketAddr
source§fn from(value: SocketAddr) -> Self
fn from(value: SocketAddr) -> Self
source§impl From<SocketAddrV4> for SocketAddr
impl From<SocketAddrV4> for SocketAddr
source§fn from(value: SocketAddrV4) -> Self
fn from(value: SocketAddrV4) -> Self
source§impl From<SocketAddrV6> for SocketAddr
impl From<SocketAddrV6> for SocketAddr
source§fn from(value: SocketAddrV6) -> Self
fn from(value: SocketAddrV6) -> Self
source§impl FromStr for SocketAddr
impl FromStr for SocketAddr
source§impl ParseArg for SocketAddr
Available on crate feature parse_arg
only.
impl ParseArg for SocketAddr
parse_arg
only.§type Error = ParseOsStrError
type Error = ParseOsStrError
Err
variant of Result
when parsing fails.source§impl<'a> TryFrom<&'a OsStr> for SocketAddr
impl<'a> TryFrom<&'a OsStr> for SocketAddr
source§impl<'a> TryFrom<&'a str> for SocketAddr
impl<'a> TryFrom<&'a str> for SocketAddr
source§impl<'a> TryFrom<DeserBorrowStr<'a>> for SocketAddr
Available on crate feature serde
only.
impl<'a> TryFrom<DeserBorrowStr<'a>> for SocketAddr
serde
only.