pub struct Server { /* private fields */ }
Expand description
The main class of this library.
Destroying this object will immediatly 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
sourceimpl Server
impl Server
sourcepub fn http<A>(
addr: A
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>>where
A: ToSocketAddrs,
pub fn http<A>(
addr: A
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>>where
A: ToSocketAddrs,
Shortcut for a simple server on a specific address.
sourcepub 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.
sourcepub fn incoming_requests(&self) -> IncomingRequests<'_> ⓘ
pub fn incoming_requests(&self) -> IncomingRequests<'_> ⓘ
Returns an iterator for all the incoming requests.
The iterator will return None
if the server socket is shutdown.
sourcepub fn server_addr(&self) -> SocketAddr
pub fn server_addr(&self) -> SocketAddr
Returns the address the server is listening to.
sourcepub fn num_connections(&self) -> usize
pub fn num_connections(&self) -> usize
Returns the number of clients currently connected to the server.
sourcepub fn recv(&self) -> IoResult<Request>
pub fn recv(&self) -> IoResult<Request>
Blocks until an HTTP request has been submitted and returns it.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe for Server
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more