# tracing_core::span::Current - Rust
API documentation for the Rust `Current` struct in crate `tracing_core`.
Keywords: rust, rustlang, rust-lang, Current

# Struct tracing_core::span::Current [−] [src]

    pub struct Current { /* fields omitted */ }

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

### `impl Current` [src]

#### `pub fn new(id: Id, metadata: &'static Metadata<'static>) -> Self` [src]

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

#### `pub fn none() -> Self` [src]

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

#### `pub fn is_known(&self) -> bool` [src]

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.

#### `pub fn into_inner(self) -> Option<(Id, &'static Metadata<'static>)>` [src]

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

#### `pub fn id(&self) -> Option<&Id>` [src]

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

#### `pub fn metadata(&self) -> Option<&'static Metadata<'static>>` [src]

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

## Trait Implementations

### `impl Debug for Current` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl<'a> Into<Option<&'a Id>> for &'a Current` [src]

#### `fn into(self) -> Option<&'a Id>` [src]

Performs the conversion.

### `impl<'a> Into<Option<&'static Metadata<'static>>> for &'a Current` [src]

#### `fn into(self) -> Option<&'static Metadata<'static>>` [src]

Performs the conversion.

### `impl<'a> Into<Option<Id>> for &'a Current` [src]

#### `fn into(self) -> Option<Id>` [src]

Performs the conversion.

### `impl Into<Option<Id>> for Current` [src]

#### `fn into(self) -> Option<Id>` [src]

Performs the conversion.

## Auto Trait Implementations

### `impl !RefUnwindSafe for Current` [src]

### `impl Send for Current` [src]

### `impl Sync for Current` [src]

### `impl Unpin for Current` [src]

### `impl !UnwindSafe for Current` [src]

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

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

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.