[−][src]Struct tide::listener::ConcurrentListener
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]
L: ToListener<State>,
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]
L: ToListener<State>,
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]
fn default() -> ConcurrentListener<State>
[src]
impl<State> Display for ConcurrentListener<State>
[src]
impl<State> Listener<State> for ConcurrentListener<State> where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
fn bind<'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,
fn accept<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn info(&self) -> Vec<ListenInfo>
[src]
impl<State> ToListener<State> for ConcurrentListener<State> where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = Self
What listener are we converting into?
fn to_listener(self) -> Result<Self::Listener>
[src]
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]
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,
pub 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> 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.
pub 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.
pub 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>,