pub struct ChildServiceContext { /* private fields */ }Expand description
A sealed, cloneable descendant of a RootServiceContext.
Libraries receive this type or a capability derived from it. They cannot construct it from a Tokio handle, create a root task group, or promote it back to a root.
Implementations§
Source§impl ChildServiceContext
impl ChildServiceContext
Sourcepub fn task_spawner(&self) -> TaskSpawner
pub fn task_spawner(&self) -> TaskSpawner
Returns the task spawner.
Sourcepub fn task_group(&self) -> &TaskGroup
pub fn task_group(&self) -> &TaskGroup
Returns the task group.
Sourcepub fn blocking(&self, lane: BlockingLane) -> &BlockingExecutor
pub fn blocking(&self, lane: BlockingLane) -> &BlockingExecutor
Returns the blocking.
Sourcepub fn storage_io(&self) -> &BlockingExecutor
pub fn storage_io(&self) -> &BlockingExecutor
Returns the storage io.
Sourcepub fn metadata_io(&self) -> &BlockingExecutor
pub fn metadata_io(&self) -> &BlockingExecutor
Returns the metadata io.
Sourcepub fn cpu_crypto(&self) -> &BlockingExecutor
pub fn cpu_crypto(&self) -> &BlockingExecutor
Returns the cpu crypto.
Sourcepub fn diagnostics(&self) -> &RuntimeDiagnostics
pub fn diagnostics(&self) -> &RuntimeDiagnostics
Returns the diagnostics.
Sourcepub fn process_budget(&self) -> ResourceBudget
pub fn process_budget(&self) -> ResourceBudget
Returns the shared process resource-budget root.
Sourcepub fn resources(&self) -> &RuntimeResources
pub fn resources(&self) -> &RuntimeResources
Returns the process-wide runtime resource capabilities.
Sourcepub fn diagnostics_snapshot(&self) -> RuntimeDiagnosticsSnapshot
pub fn diagnostics_snapshot(&self) -> RuntimeDiagnosticsSnapshot
Returns the diagnostics snapshot.
Sourcepub fn diagnostics_view_v1(
&self,
component: RuntimeComponent,
) -> RuntimeDiagnosticsViewV1
pub fn diagnostics_view_v1( &self, component: RuntimeComponent, ) -> RuntimeDiagnosticsViewV1
Returns a bounded, sanitized diagnostics view for this service subtree.
Sourcepub fn diagnostics_view_v2(
&self,
component: RuntimeComponent,
inputs: RuntimeDiagnosticsInputs,
) -> RuntimeDiagnosticsViewV2
pub fn diagnostics_view_v2( &self, component: RuntimeComponent, inputs: RuntimeDiagnosticsInputs, ) -> RuntimeDiagnosticsViewV2
Returns a bounded, explicitly scoped diagnostics view for this subtree.
The runtime context does not own scheduled groups or a metadata actor, so the caller supplies the snapshots it holds; a section without an input is reported as absent rather than as an empty value.
Sourcepub fn diagnostics_view_v2_with_options(
&self,
component: RuntimeComponent,
inputs: RuntimeDiagnosticsInputs,
options: RuntimeDiagnosticsViewOptionsV2,
) -> RuntimeDiagnosticsViewV2
pub fn diagnostics_view_v2_with_options( &self, component: RuntimeComponent, inputs: RuntimeDiagnosticsInputs, options: RuntimeDiagnosticsViewOptionsV2, ) -> RuntimeDiagnosticsViewV2
Returns a bounded, explicitly scoped diagnostics view with explicit budget limits, including the scan and output budgets of an on-demand task detail list.
Sourcepub fn component(&self, scope: impl Into<ScopeId>) -> Self
pub fn component(&self, scope: impl Into<ScopeId>) -> Self
Creates a long-lived component context owned by this service.
Dynamically supplied names must be validated with ScopeId::try_new
before they reach this boundary. Static literals may use the constrained
From<&'static str> conversion.
Sourcepub fn try_component(&self, scope: impl Into<ScopeId>) -> RuntimeResult<Self>
pub fn try_component(&self, scope: impl Into<ScopeId>) -> RuntimeResult<Self>
Creates an independently cancellable child component owned by this service.
Parent cancellation propagates to the returned component. Cancelling the child does not cancel this service or sibling components.
§Errors
Returns an unavailable runtime failure after this service starts
shutting down or becomes poisoned. Dynamically supplied names must be
validated with ScopeId::try_new before this call.
Sourcepub fn scheduled_tasks(&self, scope: impl Into<ScopeId>) -> ScheduledTaskGroup
pub fn scheduled_tasks(&self, scope: impl Into<ScopeId>) -> ScheduledTaskGroup
Returns the scheduled tasks.
Sourcepub fn spawn<F>(
&self,
name: impl Into<TaskName>,
kind: TaskKind,
future: F,
) -> RuntimeResult<TaskId>
pub fn spawn<F>( &self, name: impl Into<TaskName>, kind: TaskKind, future: F, ) -> RuntimeResult<TaskId>
Spawns the supplied task.
Sourcepub fn spawn_service<F>(
&self,
name: impl Into<TaskName>,
future: F,
) -> RuntimeResult<TaskId>
pub fn spawn_service<F>( &self, name: impl Into<TaskName>, future: F, ) -> RuntimeResult<TaskId>
Spawns a service that owns its shutdown protocol.
Use Self::spawn_cancellable_service when owner cancellation may
safely drop the service future immediately.
Sourcepub fn spawn_cancellable_service<F>(
&self,
name: impl Into<TaskName>,
future: F,
) -> RuntimeResult<TaskId>
pub fn spawn_cancellable_service<F>( &self, name: impl Into<TaskName>, future: F, ) -> RuntimeResult<TaskId>
Spawns a service that exits when either its future completes or this context is cancelled.
§Errors
Returns an error when this service context is shutting down or closed.
Sourcepub fn spawn_critical<F>(
&self,
name: impl Into<TaskName>,
kind: TaskKind,
failures: CriticalFailureState,
future: F,
) -> RuntimeResult<TaskId>
pub fn spawn_critical<F>( &self, name: impl Into<TaskName>, kind: TaskKind, failures: CriticalFailureState, future: F, ) -> RuntimeResult<TaskId>
Spawns work whose panic is recorded as a critical failure.
§Errors
Returns an error when this service context is shutting down or closed.
Sourcepub fn spawn_critical_service<F>(
&self,
name: impl Into<TaskName>,
failures: CriticalFailureState,
future: F,
) -> RuntimeResult<TaskId>
pub fn spawn_critical_service<F>( &self, name: impl Into<TaskName>, failures: CriticalFailureState, future: F, ) -> RuntimeResult<TaskId>
Spawns a critical service that must run until this context is cancelled.
§Errors
Returns an error when this service context is shutting down or closed.