pub struct Listen(CustomizableListen);Expand description
Specification of (possibly) something to listen on (eg, a port, or some addresses/ports)
Can represent, at least:
- “do not listen”
- Listen on the following port on localhost (IPv6 and IPv4)
- Listen on precisely the following address and port
- Listen on several addresses/ports
Currently only IP (v6 and v4) is supported.
Tuple Fields§
§0: CustomizableListenImplementations§
Source§impl Listen
impl Listen
Sourcepub fn new_localhost(port: u16) -> Listen
pub fn new_localhost(port: u16) -> Listen
Create a new Listen specifying listening on a port on localhost
Special case: if port is zero, specifies no listening.
Sourcepub fn new_localhost_optional(port: Option<u16>) -> Listen
pub fn new_localhost_optional(port: Option<u16>) -> Listen
Create a new Listen, possibly specifying listening on a port on localhost
Special case: if port is Some(0), also specifies no listening.
Sourcepub fn using_auto(&self) -> bool
pub fn using_auto(&self) -> bool
Return true if there are any “auto” addresses in this Listen.
See also using_port_zero().
Sourcepub fn using_port_zero(&self) -> bool
pub fn using_port_zero(&self) -> bool
Return true if there are any port-zero addresses in this Listen.
See also using_auto().
Sourcepub fn ip_addrs(
&self,
) -> Result<impl Iterator<Item = impl Iterator<Item = SocketAddr> + '_> + '_, ListenUnsupported>
pub fn ip_addrs( &self, ) -> Result<impl Iterator<Item = impl Iterator<Item = SocketAddr> + '_> + '_, ListenUnsupported>
List the network socket addresses to listen on
Each returned item is a list of SocketAddr,
of which at least one must be successfully bound.
It is OK if the others (up to all but one of them)
fail with EAFNOSUPPORT (“Address family not supported”).
This allows handling of support, or non-support,
for particular address families, eg IPv6 vs IPv4 localhost.
Other errors (eg, EADDRINUSE) should always be treated as serious problems.
Fails if the listen spec involves listening on things other than IP addresses. (Currently that is not possible.)
Sourcefn ip_addrs_internal(
&self,
) -> impl Iterator<Item = impl Iterator<Item = SocketAddr> + '_> + '_
fn ip_addrs_internal( &self, ) -> impl Iterator<Item = impl Iterator<Item = SocketAddr> + '_> + '_
List the network socket addresses to listen on.
See Self::ip_addrs, which wraps this result in an Ok.
Sourcepub fn localhost_port_legacy(&self) -> Result<Option<u16>, ListenUnsupported>
👎Deprecated since 0.38.0
pub fn localhost_port_legacy(&self) -> Result<Option<u16>, ListenUnsupported>
Get the localhost port to listen on
Returns None if listening is configured to be disabled.
Fails, giving an unsupported error, if the configuration isn’t just “listen on a single localhost port in all address families”
Sourcepub fn single_address_legacy(
&self,
) -> Result<Option<SocketAddr>, ListenUnsupported>
pub fn single_address_legacy( &self, ) -> Result<Option<SocketAddr>, ListenUnsupported>
Get a single address to listen on
Returns None if listening is configured to be disabled.
If the configuration is “listen on a single port”, treats this as a request to listening on IPv4 only. Use of this function implies a bug: lack of proper support for the current internet protocol IPv6. It should only be used if an underlying library or facility is likewise buggy.
Fails, giving an unsupported error, if the configuration isn’t just “listen on a single port on one address family”.
Sourcefn to_singleton_legacy(&self) -> Result<Option<&ListenItem>, ListenUnsupported>
fn to_singleton_legacy(&self) -> Result<Option<&ListenItem>, ListenUnsupported>
Helper: return a ListenItem if this Listen has exactly one.
Return None if there are multiple items, or an error if there are multiple items.
(Note that all users of this function are, or should be, deprecated.)
Sourcepub fn is_loopback_only(&self) -> bool
pub fn is_loopback_only(&self) -> bool
Return true if this Listen only configures listening on loopback addresses (127.0.0.0/8
and ::1).
Returns true if there are no addresses configured.
Sourcepub fn is_localhost_only(&self) -> bool
👎Deprecated since 0.37.0: please use is_loopback_only instead
pub fn is_localhost_only(&self) -> bool
please use is_loopback_only instead
Deprecated.
Use Self::is_loopback_only instead,
which behaves the same but has the correct method name.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Listen
impl<'de> Deserialize<'de> for Listen
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 From<Listen> for CustomizableListen
impl From<Listen> for CustomizableListen
Source§impl Ord for Listen
impl Ord for Listen
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Listen
impl PartialOrd for Listen
Source§impl TryFrom<CustomizableListen> for Listen
impl TryFrom<CustomizableListen> for Listen
Source§type Error = InvalidListen
type Error = InvalidListen
impl Eq for Listen
impl StructuralPartialEq for Listen
Auto Trait Implementations§
impl Freeze for Listen
impl RefUnwindSafe for Listen
impl Send for Listen
impl Sync for Listen
impl Unpin for Listen
impl UnsafeUnpin for Listen
impl UnwindSafe for Listen
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more