pub struct ShutdownHandle { /* private fields */ }Available on crate feature
std only.Expand description
Stops a running Server::serve from another thread.
§Examples
let server = http_net::blocking::Server::bind("127.0.0.1:0")?;
let stop = server.shutdown_handle();
let t = std::thread::spawn(move || server.serve(|_, _| http_net::Response::new(204)));
stop.shutdown();
t.join().unwrap()?;Implementations§
Source§impl ShutdownHandle
impl ShutdownHandle
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Asks the server to stop: it accepts no new connections and returns
from serve once every open connection has ended. The stop is
checked between exchanges, so an exchange in progress finishes. An
idle keep-alive connection ends when its read timeout passes, or
after one more request if the client sends one first; with no read
timeout, serve does not return while a client holds an idle
connection.
§Examples
See ShutdownHandle.
Trait Implementations§
Source§impl Clone for ShutdownHandle
impl Clone for ShutdownHandle
Auto Trait Implementations§
impl Freeze for ShutdownHandle
impl RefUnwindSafe for ShutdownHandle
impl Send for ShutdownHandle
impl Sync for ShutdownHandle
impl Unpin for ShutdownHandle
impl UnsafeUnpin for ShutdownHandle
impl UnwindSafe for ShutdownHandle
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