Struct tor_config::Listen
source · pub struct Listen(/* private fields */);
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.
Implementations§
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 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.)
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 in all address families”
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 Ord for Listen
impl Ord for Listen
source§impl PartialEq for Listen
impl PartialEq for Listen
source§impl PartialOrd for Listen
impl PartialOrd for Listen
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl 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§
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.