pub struct ServiceHandle { /* private fields */ }Expand description
Thread-safe handle for observing and updating service state.
Cheap to clone (Arc internals). State changes are broadcast to all subscribers via a watch channel.
Implementations§
Source§impl ServiceHandle
impl ServiceHandle
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new service handle with the given name.
Initial state is ServiceState::Stopped.
Sourcepub fn state(&self) -> ServiceState
pub fn state(&self) -> ServiceState
Get the current service state.
Sourcepub fn set_state(&self, state: ServiceState)
pub fn set_state(&self, state: ServiceState)
Update the service state.
All subscribers are notified of the change.
Sourcepub fn subscribe(&self) -> Receiver<ServiceState>
pub fn subscribe(&self) -> Receiver<ServiceState>
Subscribe to state changes.
Trait Implementations§
Source§impl Clone for ServiceHandle
impl Clone for ServiceHandle
Source§fn clone(&self) -> ServiceHandle
fn clone(&self) -> ServiceHandle
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 ServiceHandle
impl !RefUnwindSafe for ServiceHandle
impl Send for ServiceHandle
impl Sync for ServiceHandle
impl Unpin for ServiceHandle
impl UnsafeUnpin for ServiceHandle
impl !UnwindSafe for ServiceHandle
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