pub struct ScopeStack { /* private fields */ }Expand description
Mutable stack of active scopes plus their scope-local registries.
The stack always contains an implicit root scope. Additional scopes are pushed as the public API opens lifecycle spans and removed when those spans close.
Implementations§
Source§impl ScopeStack
impl ScopeStack
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new scope stack containing only the implicit root scope.
§Returns
A ScopeStack initialized with a single root scope and no
scope-local registries.
Sourcepub fn push(&mut self, handle: ScopeHandle)
pub fn push(&mut self, handle: ScopeHandle)
Push a scope handle onto the top of the stack.
§Parameters
handle: Scope handle to make the new top-most active scope.
Sourcepub fn top(&self) -> &ScopeHandle
pub fn top(&self) -> &ScopeHandle
Sourcepub fn top_mut(&mut self) -> &mut ScopeHandle
pub fn top_mut(&mut self) -> &mut ScopeHandle
Return the current top-most scope handle mutably.
§Returns
A mutable reference to the active scope at the top of the stack.
Sourcepub fn root_uuid(&self) -> Uuid
pub fn root_uuid(&self) -> Uuid
Return the UUID of the implicit root scope.
§Returns
The stable UUID of the root scope stored at the bottom of the stack.
Sourcepub fn scopes(&self) -> &[ScopeHandle]
pub fn scopes(&self) -> &[ScopeHandle]
Return the full ordered stack of scope handles.
§Returns
A slice of scopes ordered from root to the current top-most scope.
Sourcepub fn find(&self, uuid: &Uuid) -> Option<&ScopeHandle>
pub fn find(&self, uuid: &Uuid) -> Option<&ScopeHandle>
Sourcepub fn remove(&mut self, uuid: &Uuid) -> Result<ScopeHandle>
pub fn remove(&mut self, uuid: &Uuid) -> Result<ScopeHandle>
Remove the current top scope if it matches uuid.
§Parameters
uuid: UUID of the scope expected to be at the top of the stack.
§Returns
A Result containing the removed ScopeHandle.
§Errors
Returns FlowError::InvalidArgument when the scope exists but is not
the current top of the stack or when the caller attempts to remove the
implicit root scope. Returns FlowError::NotFound when the UUID is
not present on the stack.
Sourcepub fn local_registries_mut(
&mut self,
uuid: &Uuid,
) -> Option<&mut ScopeLocalRegistries>
pub fn local_registries_mut( &mut self, uuid: &Uuid, ) -> Option<&mut ScopeLocalRegistries>
Get or create the scope-local registries for an active scope.
§Parameters
uuid: UUID of an active scope on this stack.
§Returns
Some(&mut ScopeLocalRegistries) when the scope is active and None
otherwise.
§Notes
When the scope is active but has no registries yet, this function creates an empty scope-local registry set first.
Sourcepub fn collect_scope_local_registries<'a, T>(
&'a self,
field: impl Fn(&'a ScopeLocalRegistries) -> &'a SortedRegistry<T>,
) -> Vec<&'a SortedRegistry<T>>
pub fn collect_scope_local_registries<'a, T>( &'a self, field: impl Fn(&'a ScopeLocalRegistries) -> &'a SortedRegistry<T>, ) -> Vec<&'a SortedRegistry<T>>
Sourcepub fn collect_scope_local_subscribers(&self) -> Vec<EventSubscriberFn> ⓘ
pub fn collect_scope_local_subscribers(&self) -> Vec<EventSubscriberFn> ⓘ
Collect all scope-local subscribers visible from the active stack.
§Returns
A vector of subscribers collected from each active scope that owns scope-local registries.
Sourcepub fn scope_registries_get(&self, uuid: &Uuid) -> Option<&ScopeLocalRegistries>
pub fn scope_registries_get(&self, uuid: &Uuid) -> Option<&ScopeLocalRegistries>
Trait Implementations§
Source§impl Debug for ScopeStack
impl Debug for ScopeStack
Auto Trait Implementations§
impl Freeze for ScopeStack
impl !RefUnwindSafe for ScopeStack
impl Send for ScopeStack
impl Sync for ScopeStack
impl Unpin for ScopeStack
impl UnsafeUnpin for ScopeStack
impl !UnwindSafe for ScopeStack
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request