Struct Context

Source
pub struct Context<'a, N> { /* private fields */ }
Expand description

Represents the Subscriber’s view of the current span context to a formatter.

Implementations§

Source§

impl<'a, N> Context<'a, N>

Source

pub fn visit_spans<F, E>(&self, f: F) -> Result<(), E>
where F: FnMut(&Id, Span<'_>) -> Result<(), E>,

Applies a function to each span in the current trace context.

The function is applied in order, beginning with the root of the trace, and ending with the current span. If the function returns an error, this will short-circuit.

If invoked from outside of a span, the function will not be applied.

Note that if we are currently unwinding, this will do nothing, rather than potentially causing a double panic.

Source

pub fn with_current<F, R>(&self, f: F) -> Option<R>
where F: FnOnce((&Id, Span<'_>)) -> R,

Executes a closure with the reference to the current span.

Source

pub fn new_visitor<'writer>( &self, writer: &'writer mut dyn Write, is_empty: bool, ) -> <N as NewVisitor<'writer>>::Visitor
where N: NewVisitor<'writer>,

Returns a new visitor that formats span fields to the provided writer. The visitor configuration is provided by the subscriber.

Trait Implementations§

Source§

impl<'a, N> Debug for Context<'a, N>
where N: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, N> Freeze for Context<'a, N>

§

impl<'a, N> RefUnwindSafe for Context<'a, N>
where N: RefUnwindSafe,

§

impl<'a, N> Send for Context<'a, N>
where N: Sync,

§

impl<'a, N> Sync for Context<'a, N>
where N: Sync,

§

impl<'a, N> Unpin for Context<'a, N>

§

impl<'a, N> UnwindSafe for Context<'a, N>
where N: RefUnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> Erased for T