pub enum ListenAddress {
Tcp(SocketAddr),
Udp(SocketAddr),
Unixgram(PathBuf),
Unix(PathBuf),
}
Expand description
A listen address.
Listen addresses are used to bind listeners to specific local addresses and ports, and multiple address families and protocols are supported. In textual form, listen addresses are represented as URLs, with the scheme indicating the protocol and the authority/path representing the address to listen on.
§Examples
tcp://127.0.0.1:6789
(listen on IPv4 loopback, TCP port 6789)udp://[::1]:53
(listen on IPv6 loopback, UDP port 53)unixgram:///tmp/app.socket
(listen on a Unix datagram socket at/tmp/app.socket
)unix:///tmp/app.socket
(listen on a Unix stream socket at/tmp/app.socket
)
Variants§
Tcp(SocketAddr)
A TCP listen address.
Udp(SocketAddr)
A UDP listen address.
Unixgram(PathBuf)
A Unix datagram listen address.
Unix(PathBuf)
A Unix stream listen address.
Implementations§
Source§impl ListenAddress
impl ListenAddress
Sourcepub const fn any_tcp(port: u16) -> Self
pub const fn any_tcp(port: u16) -> Self
Creates a TCP address for the given port that listens on all interfaces.
Sourcepub const fn listener_type(&self) -> &'static str
pub const fn listener_type(&self) -> &'static str
Returns the socket type of the listen address.
Sourcepub fn as_local_connect_addr(&self) -> Option<SocketAddr>
pub fn as_local_connect_addr(&self) -> Option<SocketAddr>
Returns a socket address that can be used to connect to the configured listen address with a bias for local clients.
When the listen address is a TCP or UDP address, this method returns a socket address that can be used to
connect to the listener bound to this listen addresss, such that if the listen address is unspecified
(0.0.0.0
), the client will connect locally using “localhost”. When the listen address is not “unspecified” or
already uses “localhost”, this method returns the listen address as-is.
If the address is a Unix domain socket, this method returns None
.
Sourcepub fn as_unix_stream_path(&self) -> Option<&Path>
pub fn as_unix_stream_path(&self) -> Option<&Path>
Returns the Unix domain socket path if the address is a Unix domain socket in SOCK_STREAM mode.
Returns None
otherwise.
Trait Implementations§
Source§impl Clone for ListenAddress
impl Clone for ListenAddress
Source§fn clone(&self) -> ListenAddress
fn clone(&self) -> ListenAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ListenAddress
impl Debug for ListenAddress
Source§impl<'de> Deserialize<'de> for ListenAddress
impl<'de> Deserialize<'de> for ListenAddress
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 ListenAddress
impl Display for ListenAddress
Source§impl<'a> TryFrom<&'a str> for ListenAddress
impl<'a> TryFrom<&'a str> for ListenAddress
Auto Trait Implementations§
impl Freeze for ListenAddress
impl RefUnwindSafe for ListenAddress
impl Send for ListenAddress
impl Sync for ListenAddress
impl Unpin for ListenAddress
impl UnwindSafe for ListenAddress
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<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
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Stringable for Twhere
T: Display,
impl<T> Stringable for Twhere
T: Display,
SharedString
.Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read moreSource§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more