[−][src]Trait tide::listener::ToListener
ToListener represents any type that can be converted into a
Listener
. Any type that implements
ToListener can be passed to Server::listen
or
added to a ConcurrentListener
Example strings on all platforms include:
tcp://localhost:8000
tcp://0.0.0.0
(binds to port 80 by default)http://localhost:8000
(http is an alias for tcp)http://127.0.0.1:8000
(or0.0.0.0
, or some specific bindable ip)127.0.0.1:3000
(or any string that can be parsed as a SocketAddr)[::1]:1213
(an ipv6 SocketAddr)
Strings supported only on cfg(unix)
platforms:
http+unix:///var/run/tide/socket
(absolute path)http+unix://socket
(relative path)http+unix://./socket.file
(also relative path)http+unix://../socket
(relative path)
String supported only on windows:
:3000
(binds to port 3000)
Specifying multiple listeners:
To bind to any number of listeners concurrently:
app.listen(vec!["tcp://localhost:8000", "tcp://localhost:8001"]).await?;
Multiple socket resolution
If a TCP listener resolves to multiple socket addresses, tide will
bind to the first successful one. For example, on ipv4+ipv6
systems, tcp://localhost:1234
resolves both to 127.0.0.1:1234
(v4) as well as [::1]:1234
(v6). The order that these are
attempted is platform-determined. To listen on all of the addresses, use
use std::net::ToSocketAddrs; app.listen("localhost:8000".to_socket_addrs()?.collect::<Vec<_>>()).await?;
Other implementations
See below for additional provided implementations of ToListener.
Associated Types
Loading content...Required methods
fn to_listener(self) -> Result<Self::Listener>
[src]
Transform self into a
Listener
. Unless self is
already bound/connected to the underlying io, converting to a
listener does not initiate a connection. An Err return
indicates an unsuccessful conversion to a listener, not an
unsuccessful bind attempt.
Implementations on Foreign Types
impl<State> ToListener<State> for Url where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = ParsedListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for String where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = ParsedListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for &String where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = ParsedListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for &str where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = ParsedListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for PathBuf where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = UnixListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for PathBuf where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = UnixListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for TcpListener where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = TcpListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for TcpListener where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = TcpListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for (String, u16) where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = TcpListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for (&String, u16) where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = TcpListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for (&str, u16) where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = TcpListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for UnixListener where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = UnixListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for UnixListener where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = UnixListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for SocketAddr where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = TcpListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<L, State> ToListener<State> for Vec<L> where
L: ToListener<State>,
State: Clone + Send + Sync + 'static,
[src]
L: ToListener<State>,
State: Clone + Send + Sync + 'static,
type Listener = ConcurrentListener<State>
fn to_listener(self) -> Result<Self::Listener>
[src]
Implementors
impl<State> ToListener<State> for ConcurrentListener<State> where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,
type Listener = Self
fn to_listener(self) -> Result<Self::Listener>
[src]
impl<State> ToListener<State> for FailoverListener<State> where
State: Clone + Send + Sync + 'static,
[src]
State: Clone + Send + Sync + 'static,