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_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.