pub struct ServerStopHandle { /* private fields */ }Expand description
Handle that allows stopping the server from another thread.
This handle can be cloned and shared across threads. It provides a way for external code to request a graceful shutdown of the server.
§Thread Safety
ServerStopHandle is Clone + Send + Sync and can be safely shared between
threads. Multiple calls to stop() are safe and idempotent.
§Example
ⓘ
let mut server = Server::new(None, "/path/to/socket")?;
let handle = server.get_stop_handle();
// In another thread:
std::thread::spawn(move || {
// ... some condition ...
handle.stop();
});
server.run()?; // Will exit when stop() is calledImplementations§
Source§impl ServerStopHandle
impl ServerStopHandle
Sourcepub fn stop(&self)
pub fn stop(&self)
Request the server to stop.
This method is idempotent - multiple calls are safe. The server will exit its run loop on the next iteration.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the server is still running.
Returns true if the server has not been requested to stop,
false if stop() has been called.
Trait Implementations§
Source§impl Clone for ServerStopHandle
impl Clone for ServerStopHandle
Source§fn clone(&self) -> ServerStopHandle
fn clone(&self) -> ServerStopHandle
Returns a duplicate 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 ServerStopHandle
impl RefUnwindSafe for ServerStopHandle
impl Send for ServerStopHandle
impl Sync for ServerStopHandle
impl Unpin for ServerStopHandle
impl UnwindSafe for ServerStopHandle
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