[−][src]Struct tiny_http::Server
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.
Methods
impl Server
[src]
pub fn http<A>(
addr: A
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
[src]
addr: A
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
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,
[src]
config: ServerConfig<A>
) -> Result<Server, Box<dyn Error + Send + Sync + 'static>> where
A: ToSocketAddrs,
Builds a new server that listens on the specified address.
ⓘImportant traits for IncomingRequests<'a>pub fn incoming_requests(&self) -> IncomingRequests
[src]
Returns an iterator for all the incoming requests.
The iterator will return None
if the server socket is shutdown.
pub fn server_addr(&self) -> SocketAddr
[src]
Returns the address the server is listening to.
pub fn num_connections(&self) -> usize
[src]
Returns the number of clients currently connected to the server.
pub fn recv(&self) -> IoResult<Request>
[src]
Blocks until an HTTP request has been submitted and returns it.
pub fn recv_timeout(&self, timeout: Duration) -> IoResult<Option<Request>>
[src]
Same as recv()
but doesn't block longer than timeout
pub fn try_recv(&self) -> IoResult<Option<Request>>
[src]
Same as recv()
but doesn't block.
Trait Implementations
Auto Trait Implementations
impl Unpin for Server
impl Sync for Server
impl Send for Server
impl !UnwindSafe for Server
impl !RefUnwindSafe for Server
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,