pub(crate) struct Listen(Vec<ListenItem, Global>);
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: Vec<ListenItem, Global>
Implementations
sourceimpl 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 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 faimilies, 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.)
sourcepub fn localhost_port_legacy(&self) -> Result<Option<u16>, ListenUnsupported>
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”.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Listen
impl<'de> Deserialize<'de> for Listen
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Listen, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Listen, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Listen
impl Ord for Listen
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Listen> for Listen
impl PartialEq<Listen> for Listen
sourceimpl PartialOrd<Listen> for Listen
impl PartialOrd<Listen> for Listen
sourcefn partial_cmp(&self, other: &Listen) -> Option<Ordering>
fn partial_cmp(&self, other: &Listen) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Listen
impl Serialize for Listen
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl TryFrom<ListenSerde> for Listen
impl TryFrom<ListenSerde> for Listen
type Error = InvalidListen
type Error = InvalidListen
The type returned in the event of a conversion error.
sourcefn try_from(
l: ListenSerde
) -> Result<Listen, <Listen as TryFrom<ListenSerde>>::Error>
fn try_from(
l: ListenSerde
) -> Result<Listen, <Listen as TryFrom<ListenSerde>>::Error>
Performs the conversion.
impl Eq for Listen
impl StructuralEq for Listen
impl StructuralPartialEq for Listen
Auto Trait Implementations
impl RefUnwindSafe for Listen
impl Send for Listen
impl Sync for Listen
impl Unpin for Listen
impl UnwindSafe for Listen
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more