Struct tracing_core::span::Current

source ·
pub struct Current { /* private fields */ }
Expand description

Indicates what the Subscriber considers the “current” span.

As subscribers may not track a notion of a current span, this has three possible states:

  • “unknown”, indicating that the subscriber does not track a current span,
  • “none”, indicating that the current context is known to not be in a span,
  • “some”, with the current span’s Id and Metadata.

Implementations§

source§

impl Current

source

pub fn new(id: Id, metadata: &'static Metadata<'static>) -> Self

Constructs a new Current that indicates the current context is a span with the given metadata and metadata.

source

pub fn none() -> Self

Constructs a new Current that indicates the current context is not in a span.

source

pub fn is_known(&self) -> bool

Returns true if the Subscriber that constructed this Current tracks a current span.

If this returns true and id, metadata, or into_inner return None, that indicates that we are currently known to not be inside a span. If this returns false, those methods will also return None, but in this case, that is because the subscriber does not keep track of the currently-entered span.

source

pub fn into_inner(self) -> Option<(Id, &'static Metadata<'static>)>

Consumes self and returns the span Id and Metadata of the current span, if one exists and is known.

source

pub fn id(&self) -> Option<&Id>

Borrows the Id of the current span, if one exists and is known.

source

pub fn metadata(&self) -> Option<&'static Metadata<'static>>

Borrows the Metadata of the current span, if one exists and is known.

Trait Implementations§

source§

impl Debug for Current

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Current> for Option<&'a Id>

source§

fn from(cur: &'a Current) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Current> for Option<&'static Metadata<'static>>

source§

fn from(cur: &'a Current) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Current> for Option<Id>

source§

fn from(cur: &'a Current) -> Self

Converts to this type from the input type.
source§

impl From<Current> for Option<Id>

source§

fn from(cur: Current) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.