pub struct ResourceScope { /* private fields */ }Expand description
One trusted-host scope. Clones are access capabilities, never ownership transfers; resource finalization remains retained by the shared scope.
Implementations§
Source§impl ResourceScope
impl ResourceScope
Sourcepub async fn run_in_scope<F>(&self, future: F) -> F::Outputwhere
F: Future,
pub async fn run_in_scope<F>(&self, future: F) -> F::Outputwhere
F: Future,
Carry host ownership through directly awaited async work. Tokio task locals do not propagate through a separately spawned task or a blocking runtime entry; those boundaries must install this scope explicitly.
Sourcepub fn spawn_blocking<F, T>(
&self,
operation_name: impl Into<String>,
work: F,
) -> Result<JoinHandle<T>, AdmissionClosed>
pub fn spawn_blocking<F, T>( &self, operation_name: impl Into<String>, work: F, ) -> Result<JoinHandle<T>, AdmissionClosed>
Admit before dispatch and retain the lease in the blocking closure, including after a waiting caller disappears. Panic is an acknowledged failed worker outcome and remains in the owning resource report.
pub fn downgrade(&self) -> WeakResourceScope
Sourcepub fn retain_resource_state<T>(
&self,
state: Arc<T>,
) -> Result<(), LifecycleRegistrationError>
pub fn retain_resource_state<T>( &self, state: Arc<T>, ) -> Result<(), LifecycleRegistrationError>
Retain the resource’s actual state after a failed finalizer, so failure reporting cannot abandon ownership of handles needing explicit recovery. The state must use weak scope references to avoid an ownership cycle.
Sourcepub fn resource_state<T>(&self) -> Option<Arc<T>>
pub fn resource_state<T>(&self) -> Option<Arc<T>>
Observe retained host resource state without reopening admission.
Sourcepub fn standalone(
resource_id: impl Into<String>,
owner: impl Into<String>,
) -> Self
pub fn standalone( resource_id: impl Into<String>, owner: impl Into<String>, ) -> Self
Create an independently owned scope for an embedding that does not use
a process-wide supervisor. The embedding must call Self::close as
part of its own shutdown contract.
Sourcepub fn mark_ready(&self) -> Result<(), LifecycleReadinessError>
pub fn mark_ready(&self) -> Result<(), LifecycleReadinessError>
Publish that this scope can accept work after its owner has completed all startup dependencies.
Sourcepub fn set_finalizer<F>(
&self,
finalizer: F,
) -> Result<(), LifecycleRegistrationError>
pub fn set_finalizer<F>( &self, finalizer: F, ) -> Result<(), LifecycleRegistrationError>
Register the one resource-specific closure operation before the owner exposes the resource to other runtime work.
Sourcepub fn set_ownership(
&self,
ownership: ResourceOwnership,
) -> Result<(), AdmissionClosed>
pub fn set_ownership( &self, ownership: ResourceOwnership, ) -> Result<(), AdmissionClosed>
Declare whether this scope owns the underlying resource. Borrowed resources release only their UAR capability during finalization.
Sourcepub fn declare_dependencies<I, S>(
&self,
dependencies: I,
) -> Result<(), AdmissionClosed>
pub fn declare_dependencies<I, S>( &self, dependencies: I, ) -> Result<(), AdmissionClosed>
Declare resources that must remain usable while this scope finalizes. The supervisor exposes these edges in every resource snapshot.
Sourcepub fn admit(&self) -> Result<OperationLease, AdmissionClosed>
pub fn admit(&self) -> Result<OperationLease, AdmissionClosed>
Atomically verify admission and account for an operation.
Sourcepub fn admit_named(
&self,
name: impl AsRef<str>,
) -> Result<OperationLease, AdmissionClosed>
pub fn admit_named( &self, name: impl AsRef<str>, ) -> Result<OperationLease, AdmissionClosed>
Atomically register a named operation. The stable generated ID remains visible in snapshots until acknowledged completion.
Sourcepub fn spawn<F>(
&self,
task_name: impl Into<String>,
future: F,
) -> Result<(), AdmissionClosed>
pub fn spawn<F>( &self, task_name: impl Into<String>, future: F, ) -> Result<(), AdmissionClosed>
Register a task only after its operation lease has been admitted.
Task errors and panics are retained in the close report. The task keeps no strong reference to a supervisor, only to this resource scope.
Sourcepub fn close_admission(&self)
pub fn close_admission(&self)
Stop new work. This operation is idempotent and does not await cleanup.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
A cancellation signal for work already admitted to this scope.
Sourcepub fn subscribe(&self) -> Receiver<ResourceSnapshot>
pub fn subscribe(&self) -> Receiver<ResourceSnapshot>
Retained lifecycle state for current and late subscribers.
pub fn snapshot(&self) -> ResourceSnapshot
Sourcepub fn close_report(&self) -> Option<CloseReport>
pub fn close_report(&self) -> Option<CloseReport>
Read the retained terminal report without starting or awaiting closure. Control-plane callers use this to inspect unresolved durable effects after an independently-owned finalizer has completed.
Sourcepub fn record_unresolved_effect(&self, effect: impl Into<String>)
pub fn record_unresolved_effect(&self, effect: impl Into<String>)
Report a durable effect whose outcome cannot be established locally.
Sourcepub fn record_failure(&self, failure: impl Into<String>)
pub fn record_failure(&self, failure: impl Into<String>)
Retain a local cleanup failure without fabricating a released state.
Sourcepub fn record_child_report(&self, report: CloseReport)
pub fn record_child_report(&self, report: CloseReport)
Preserve a child scope’s terminal report in this scope’s final result.
Sourcepub async fn close(&self) -> CloseReport
pub async fn close(&self) -> CloseReport
Begin one retained finalizer and await its retained result.
A cancelled caller only drops its wait. The spawned finalizer remains owned by this scope and all later callers observe the same report.
Trait Implementations§
Source§impl Clone for ResourceScope
impl Clone for ResourceScope
Source§fn clone(&self) -> ResourceScope
fn clone(&self) -> ResourceScope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ResourceScope
impl !UnwindSafe for ResourceScope
impl Freeze for ResourceScope
impl Send for ResourceScope
impl Sync for ResourceScope
impl Unpin for ResourceScope
impl UnsafeUnpin for ResourceScope
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
impl<T> AsyncFriendly for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Message for T
impl<T> Message for T
§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T> OutputMessage for Twhere
T: Message + Clone,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<T> State for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.