pub struct Server<L = HttpListener> { /* private fields */ }
Expand description
A server can listen on a TCP socket.
Once listening, it will create a Request
/Response
pair for each
incoming connection, and hand them to the provided handler.
Implementations§
source§impl<L> Server<L>where
L: NetworkListener,
impl<L> Server<L>where
L: NetworkListener,
sourcepub fn keep_alive(&mut self, timeout: Option<Duration>)
pub fn keep_alive(&mut self, timeout: Option<Duration>)
Controls keep-alive for this server.
The timeout duration passed will be used to determine how long to keep the connection alive before dropping it.
Passing None
will disable keep-alive.
Default is enabled with a 5 second timeout.
sourcepub fn set_read_timeout(&mut self, dur: Option<Duration>)
pub fn set_read_timeout(&mut self, dur: Option<Duration>)
Sets the read timeout for all Request reads.
sourcepub fn set_write_timeout(&mut self, dur: Option<Duration>)
pub fn set_write_timeout(&mut self, dur: Option<Duration>)
Sets the write timeout for all Response writes.
sourcepub fn local_addr(&mut self) -> Result<SocketAddr, Error>
pub fn local_addr(&mut self) -> Result<SocketAddr, Error>
Get the address that the server is listening on.
source§impl<S> Server<HttpsListener<S>>
impl<S> Server<HttpsListener<S>>
sourcepub fn https<A>(addr: A, ssl: S) -> Result<Server<HttpsListener<S>>, Error>where
A: ToSocketAddrs,
pub fn https<A>(addr: A, ssl: S) -> Result<Server<HttpsListener<S>>, Error>where
A: ToSocketAddrs,
Creates a new server that will handle HttpStream
s over SSL.
You can use any SSL implementation, as long as implements hyper::net::Ssl
.
Trait Implementations§
Auto Trait Implementations§
impl<L> Freeze for Server<L>where
L: Freeze,
impl<L> RefUnwindSafe for Server<L>where
L: RefUnwindSafe,
impl<L> Send for Server<L>where
L: Send,
impl<L> Sync for Server<L>where
L: Sync,
impl<L> Unpin for Server<L>where
L: Unpin,
impl<L> UnwindSafe for Server<L>where
L: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more