pub struct Server { /* fields omitted */ }Expand description
The main class of this library.
Destroying this object will immediately close the listening socket and the reading
part of all the client’s connections. Requests that have already been returned by
the recv() function will not close and the responses will be transferred to the client.
Implementations
Shortcut for a simple server on a specific address.
pub fn new<A>(
config: ServerConfig<A>
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
pub fn new<A>(
config: ServerConfig<A>
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
Builds a new server that listens on the specified address.
Builds a new server using the specified TCP listener.
This is useful if you’ve constructed TcpListener using some less usual method
such as from systemd. For other cases, you probably want the new() function.
pub fn incoming_requests(&self) -> IncomingRequests<'_>ⓘNotable traits for IncomingRequests<'_>impl Iterator for IncomingRequests<'_> type Item = Request;
pub fn incoming_requests(&self) -> IncomingRequests<'_>ⓘNotable traits for IncomingRequests<'_>impl Iterator for IncomingRequests<'_> type Item = Request;
impl Iterator for IncomingRequests<'_> type Item = Request;Returns an iterator for all the incoming requests.
The iterator will return None if the server socket is shutdown.
Returns the address the server is listening to.
Returns the number of clients currently connected to the server.
Blocks until an HTTP request has been submitted and returns it.
Same as recv() but doesn’t block longer than timeout
