[][src]Struct mini_async_http::ServerHandle

pub struct ServerHandle { /* fields omitted */ }

Clonable handle to a server. Can only be retrieved from a Server instance. Used to wait for the server to be ready or to shut it down.

Implementations

impl ServerHandle[src]

pub fn shutdown(&self)[src]

Send a shutdown signal to the server. The server wait for all the received request to be handled and the stop

Example

Creates a server and starts it. From another thread we send the shutdown signal causing the server to stop and the program to end.

let mut server = mini_async_http::AIOServer::new(3, "0.0.0.0:7880", move |request|{
    mini_async_http::ResponseBuilder::empty_200()
        .body(b"Hello")
        .content_type("text/plain")
        .build()
        .unwrap()
});
let handle = server.handle();

std::thread::spawn(move || {
    handle.shutdown();
});

server.start();

pub fn ready(&self)[src]

Block untill the server is ready to receive requests

Example

Creates a server and starts it in a separate thread. The main thread waits for the server to be ready and then ends

let mut server = mini_async_http::AIOServer::new(3, "0.0.0.0:7880", move |request|{
    mini_async_http::ResponseBuilder::empty_200()
        .body(b"Hello")
        .content_type("text/plain")
        .build()
        .unwrap()
});
let handle = server.handle();

std::thread::spawn(move || {
    server.start();
});

handle.ready();

Trait Implementations

impl Clone for ServerHandle[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.