Enum Listener

Source
pub enum Listener {
    Tcp(TcpListenerInfo),
    Uds(UdsListenerInfo),
    TlsTcp(TlsTcpListenerInfo),
}
Expand description

Wrapper around common protocol-specific listener specifiers.

Variants§

Implementations§

Source§

impl Listener

Source

pub fn tcp(s: &str) -> Result<Listener, Error>

Create a TCP listener from a string.

§Errors

An error means the listener address specification string could not be parsed.

Source

pub fn uds(s: &str) -> Result<Listener, Error>

Create an unix domain socket listener from a string.

§Errors

An error means the listener address specification string could not be parsed.

Source§

impl Listener

Source

pub async fn run( &self, ks: KillSwitch, acceptor: impl Acceptor + Send, ) -> Result<(), Error>

Run a listener loop.

If the socket bind is successful the Acceptor::bound() of acceptor will be called, where the bound socket address will be passed as an argument. (This can be used to retreive the port number if the application requested the port number to be automatically assigned.

Each time a client has connected the acceptor will call Acceptor::connected() to allow the application to process the connection. The ownership of the newly established connection will be passed to the connected() method.

§Unix domain sockets

If the listener is a unix domain socket, the socket file will be removed if the listener is aborted.

§Errors

Error::IO can indicate the inability to bind socket.

For “forced” UDS sockets, an ErrorKind::Other is returned if the file already exists and is not a socket.

Trait Implementations§

Source§

impl From<TcpListenerInfo> for Listener

Source§

fn from(info: TcpListenerInfo) -> Listener

Converts to this type from the input type.
Source§

impl From<TlsTcpListenerInfo> for Listener

Source§

fn from(info: TlsTcpListenerInfo) -> Listener

Converts to this type from the input type.
Source§

impl From<UdsListenerInfo> for Listener

Source§

fn from(info: UdsListenerInfo) -> Listener

Converts to this type from the input type.
Source§

impl FromStr for Listener

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Listener, <Listener as FromStr>::Err>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.