[][src]Struct tide::listener::ConcurrentListener

pub struct ConcurrentListener<State> { /* fields omitted */ }

ConcurrentListener allows tide to listen on any number of transports simultaneously (such as tcp ports, unix sockets, or tls).

Example:

fn main() -> Result<(), std::io::Error> {
   async_std::task::block_on(async {
       tide::log::start();
       let mut app = tide::new();
       app.at("/").get(|_| async { Ok("Hello, world!") });

       let mut listener = tide::listener::ConcurrentListener::new();
       listener.add("127.0.0.1:8000")?;
       listener.add(async_std::net::TcpListener::bind("127.0.0.1:8001").await?)?;
       listener.add("http+unix://unix.socket")?;
   
       app.listen(listener).await?;
       Ok(())
   })
}

Implementations

impl<State: Clone + Send + Sync + 'static> ConcurrentListener<State>[src]

pub fn new() -> Self[src]

creates a new ConcurrentListener

pub fn add<L>(&mut self, listener: L) -> Result<()> where
    L: ToListener<State>, 
[src]

Adds any ToListener to this ConcurrentListener. An error result represents a failure to convert the ToListener into a Listener.

let mut listener = tide::listener::ConcurrentListener::new();
listener.add("127.0.0.1:8000")?;
listener.add(("localhost", 8001))?;
listener.add(std::net::TcpListener::bind(("localhost", 8002))?)?;

pub fn with_listener<L>(self, listener: L) -> Self where
    L: ToListener<State>, 
[src]

ConcurrentListener::with_listener allows for chained construction of a ConcurrentListener:

app.listen(
    ConcurrentListener::new()
        .with_listener("127.0.0.1:8080")
        .with_listener(async_std::net::TcpListener::bind("127.0.0.1:8081").await?),
).await?;

Trait Implementations

impl<State> Debug for ConcurrentListener<State>[src]

impl<State: Default> Default for ConcurrentListener<State>[src]

impl<State> Display for ConcurrentListener<State>[src]

impl<State> Listener<State> for ConcurrentListener<State> where
    State: Clone + Send + Sync + 'static, 
[src]

impl<State> ToListener<State> for ConcurrentListener<State> where
    State: Clone + Send + Sync + 'static, 
[src]

type Listener = Self

What listener are we converting into?

Auto Trait Implementations

impl<State> !RefUnwindSafe for ConcurrentListener<State>

impl<State> Send for ConcurrentListener<State>

impl<State> Sync for ConcurrentListener<State>

impl<State> Unpin for ConcurrentListener<State>

impl<State> !UnwindSafe for ConcurrentListener<State>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,