pub struct ServiceHandle { /* private fields */ }Expand description
Shared handle for spawning, stopping, and inspecting managed services.
Implementations§
Source§impl ServiceHandle
impl ServiceHandle
Sourcepub fn new(service: Arc<dyn ManagedService>, context: ServiceContext) -> Self
pub fn new(service: Arc<dyn ManagedService>, context: ServiceContext) -> Self
Creates a new handle around a service and context.
Sourcepub fn named(
name: impl Into<String>,
protocol: Option<Protocol>,
service: Arc<dyn ManagedService>,
) -> Self
pub fn named( name: impl Into<String>, protocol: Option<Protocol>, service: Arc<dyn ManagedService>, ) -> Self
Creates a handle for a named service.
Sourcepub fn context(&self) -> ServiceContext
pub fn context(&self) -> ServiceContext
Returns the shared service context.
Sourcepub async fn spawn(&self) -> RuntimeResult<()>
pub async fn spawn(&self) -> RuntimeResult<()>
Spawns the service task if it is not already running.
Sourcepub async fn stop(&self) -> RuntimeResult<()>
pub async fn stop(&self) -> RuntimeResult<()>
Requests service shutdown and waits for the service task.
Sourcepub async fn wait(&self) -> RuntimeResult<()>
pub async fn wait(&self) -> RuntimeResult<()>
Waits for the service task to finish if it was spawned.
Sourcepub async fn readiness(
&self,
max_wait: Duration,
) -> RuntimeResult<ServiceStatus>
pub async fn readiness( &self, max_wait: Duration, ) -> RuntimeResult<ServiceStatus>
Waits until the service reports readiness or the timeout elapses.
Sourcepub fn status(&self) -> ServiceStatus
pub fn status(&self) -> ServiceStatus
Returns the latest status.
Sourcepub async fn snapshot(&self) -> RuntimeResult<ServiceSnapshot>
pub async fn snapshot(&self) -> RuntimeResult<ServiceSnapshot>
Returns the latest snapshot.
Auto 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