[][src]Struct tide::listener::FailoverListener

pub struct FailoverListener<State>(_);

FailoverListener allows tide to attempt to listen in a sequential order to any number of ports/addresses. The first successful listener is used.

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::FailoverListener::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> FailoverListener<State>[src]

pub fn new() -> Self[src]

creates a new FailoverListener

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

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

let mut listener = tide::listener::FailoverListener::new();
listener.add("127.0.0.1:8000")?;
listener.add(("localhost", 8001))?;
listener.add("http+unix:///var/run/tide")?;

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

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

app.listen(
    FailoverListener::new()
        .with_listener("127.0.0.1:8080")
        .with_listener(("localhost", 8081)),
).await?;

Trait Implementations

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

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

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

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

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

type Listener = Self

Auto Trait Implementations

impl<State> !RefUnwindSafe for FailoverListener<State>

impl<State> Send for FailoverListener<State>

impl<State> Sync for FailoverListener<State>

impl<State> Unpin for FailoverListener<State>

impl<State> !UnwindSafe for FailoverListener<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> Sealed<T> for T where
    T: ?Sized

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>,