[−][src]Struct tide::listener::FailoverListener
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]
fn default() -> FailoverListener<State>
[src]
impl<State> Display for FailoverListener<State>
[src]
impl<State: Clone + Send + Sync + 'static> Listener<State> for FailoverListener<State>
[src]
fn listen<'life0, 'async_trait>(
&'life0 mut self,
app: Server<State>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
app: Server<State>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
impl<State: Clone + Send + Sync + 'static> ToListener<State> for FailoverListener<State>
[src]
type Listener = Self
fn to_listener(self) -> Result<Self::Listener>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,