🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

tracing_core::span

Struct Current

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

Indicates what the collector considers the “current” span.

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

  • “unknown”, indicating that the collector 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 id and metadata.

Source

pub fn none() -> Self

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

Source

pub fn unknown() -> Self

Constructs a new Current that indicates the collector does not track a current span.

Source

pub fn is_known(&self) -> bool

Returns true if the collector 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 collector 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 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.