pub struct Registry(/* private fields */);
Expand description
The registry of multiple await-trees.
Can be cheaply cloned to share the same registry.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn try_current() -> Option<Self>
pub fn try_current() -> Option<Self>
Returns the current registry, if exists.
- If the current task is registered with a registry, returns the registry.
- If the global registry is initialized with
init_global_registry
, returns the global registry. - Otherwise, returns
None
.
Sourcepub fn current() -> Self
pub fn current() -> Self
Returns the current registry, panics if not exists.
See Registry::try_current
for more information.
Sourcepub fn register_derived_root(&self, key: impl Key + ToRootSpan) -> TreeRoot
pub fn register_derived_root(&self, key: impl Key + ToRootSpan) -> TreeRoot
Derive the root span from the given key and register with it.
This is a convenience method for self.register(key, key.to_root_span())
. See
Registry::register
for more details.
Sourcepub fn register_anonymous(&self, root_span: impl Into<Span>) -> TreeRoot
pub fn register_anonymous(&self, root_span: impl Into<Span>) -> TreeRoot
Register an anonymous await-tree without specifying a key. Returns a TreeRoot
that can
be used to instrument a future.
Anonymous await-trees are not able to be retrieved through the Registry::get
method. Use
Registry::collect_anonymous
or Registry::collect_all
to collect them.
Sourcepub fn get(&self, key: impl Key) -> Option<Tree>
pub fn get(&self, key: impl Key) -> Option<Tree>
Get a clone of the await-tree with given key.
Returns None
if the key does not exist or the tree root has been dropped.
Sourcepub fn collect<K: Key + Clone>(&self) -> Vec<(K, Tree)>
pub fn collect<K: Key + Clone>(&self) -> Vec<(K, Tree)>
Collect the snapshots of all await-trees with the key of type K
.
Sourcepub fn collect_anonymous(&self) -> Vec<Tree>
pub fn collect_anonymous(&self) -> Vec<Tree>
Collect the snapshots of all await-trees registered with Registry::register_anonymous
.
Sourcepub fn collect_all(&self) -> Vec<(AnyKey, Tree)>
pub fn collect_all(&self) -> Vec<(AnyKey, Tree)>
Collect the snapshots of all await-trees regardless of the key type.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Registry
impl !RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl !UnwindSafe for Registry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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