Skip to main content

Ctx

Struct Ctx 

Source
pub struct Ctx { /* private fields */ }
Expand description

A captured trace scope: a tracer plus the current span id. Get one with current() and re-enter it in a spawned task or a blocking closure with enter or in_scope, so parents stay right.

Implementations§

Source§

impl Ctx

Source

pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R

Runs f with this scope current on this thread, restoring the previous scope afterwards, also when f panics. Input: the closure. Output: its result.

Source

pub fn in_scope<F: Future>(&self, fut: F) -> Instrumented<F> ⓘ

Wraps fut so this scope is current on every poll. Input: the future. Output: the wrapped future.

Source

pub fn nest(&self, categories: TraceSet, content: Option<bool>) -> Ctx

Returns a scope in the same trace and sink with categories added. content replaces this scope’s content flag when given. Input: extra categories and an optional flag. Output: the nested scope.

Source

pub fn trace_id(&self) -> u64

Returns the trace id. Input: none. Output: the id.

Source

pub fn span_id(&self) -> u64

Returns the current span id, 0 at the root. Input: none. Output: the id.

Source

pub fn categories(&self) -> TraceSet

Returns the categories of this scope. Input: none. Output: the set.

Source

pub fn content(&self) -> bool

Returns whether this scope keeps content. Input: none. Output: the flag.

Trait Implementations§

Source§

impl Clone for Ctx

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Ctx

§

impl !UnwindSafe for Ctx

§

impl Forget for Ctx

§

impl Freeze for Ctx
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for Ctx

§

impl Send for Ctx
where Arc<Inner>: Send,

§

impl Sync for Ctx
where Arc<Inner>: Sync,

§

impl Unpin for Ctx
where Arc<Inner>: Unpin,

§

impl UnsafeUnpin for Ctx
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.