#[non_exhaustive]pub enum ListenerAddress {
Tcp(SocketAddr),
Path(PathBuf),
Abstract(String),
Inetd,
FromFd(i32),
FromFdNamed(String),
}
Expand description
Abstraction over socket address that instructs in which way and at what address (if any) [Listener
]
should listen for incoming stream connections.
All address variants are available on all platforms, regardness of actual support in the Listener or enabled crate features.
If serde is enabled, it is serialized/deserialized the same as string, same as as in the CLI, using FromStr
/Display
.
See variants documentation for FromStr
string patterns that are accepted by ListenerAddress
parser
If you are not using clap helper types then remember to copy or link those documentation snippets into your app’s documentation.
let addr : ListenerAddress = "127.0.0.1:8087".parse().unwrap();
let addr : ListenerAddress = "[::]:80".parse().unwrap();
let addr : ListenerAddress = "/path/to/socket".parse().unwrap();
let addr : ListenerAddress = "@abstract_linux_address".parse().unwrap();
let addr : ListenerAddress = "inetd".parse().unwrap();
let addr : ListenerAddress = "sd-listen".parse().unwrap();
let addr : ListenerAddress = "SD_LISTEN".parse().unwrap();
let addr : ListenerAddress = "sd-listen:named_socket".parse().unwrap();
let addr : ListenerAddress = "sd-listen:*".parse().unwrap();
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Tcp(SocketAddr)
Usual server TCP socket. Triggered by specifying IPv4 or IPv6 address and port pair.
Example: 127.0.0.1:8080
.
Hostnames are not supported.
Path(PathBuf)
Path-based UNIX socket. Path must begin with /
or .
.
Examples: /tmp/mysock
, ./mysock
Abstract(String)
Linux abstract-namespaced UNIX socket. Indicated by using @
as a first character.
Example: @server
Inetd
“inetd” or “Accept=yes” mode where stdin and stdout (file descriptors 0 and 1) are used together as a socket
and only one connection is served. Triggered by using inetd
or stdio
or -
as the address.
FromFd(i32)
SystemD’s “Accept=no” mode - using manually specified file descriptor as a pre-created server socket ready to accept TCP or UNIX connections.
Triggered by specifying sd-listen
as address, which sets 3
as file descriptor number.
FromFdNamed(String)
SystemD’s “Accept=no” mode - relying on LISTEN_FDNAMES
environment variable instead of using the hard coded number
Triggered by using appending a colon and a name after sd-listen
. Example: sd-listen:mynamedsock
Special name *
means to bind all passed addresses simultaneously, if multi-listener
crate feature is enabled.
Trait Implementations§
Source§impl Clone for ListenerAddress
impl Clone for ListenerAddress
Source§fn clone(&self) -> ListenerAddress
fn clone(&self) -> ListenerAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ListenerAddress
impl Debug for ListenerAddress
Source§impl Display for ListenerAddress
impl Display for ListenerAddress
Source§impl FromStr for ListenerAddress
impl FromStr for ListenerAddress
Source§impl Hash for ListenerAddress
impl Hash for ListenerAddress
Source§impl Ord for ListenerAddress
impl Ord for ListenerAddress
Source§fn cmp(&self, other: &ListenerAddress) -> Ordering
fn cmp(&self, other: &ListenerAddress) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ListenerAddress
impl PartialEq for ListenerAddress
Source§impl PartialOrd for ListenerAddress
impl PartialOrd for ListenerAddress
impl Eq for ListenerAddress
impl StructuralPartialEq for ListenerAddress
Auto Trait Implementations§
impl Freeze for ListenerAddress
impl RefUnwindSafe for ListenerAddress
impl Send for ListenerAddress
impl Sync for ListenerAddress
impl Unpin for ListenerAddress
impl UnwindSafe for ListenerAddress
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request