pub struct ServerHandle { /* private fields */ }
Expand description
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§
Source§impl ServerHandle
impl ServerHandle
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
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();
Sourcepub fn ready(&self)
pub fn ready(&self)
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§
Source§impl Clone for ServerHandle
impl Clone for ServerHandle
Source§fn clone(&self) -> ServerHandle
fn clone(&self) -> ServerHandle
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ServerHandle
impl RefUnwindSafe for ServerHandle
impl Send for ServerHandle
impl Sync for ServerHandle
impl Unpin for ServerHandle
impl UnwindSafe for ServerHandle
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