Trait tracing_subscriber::field::RecordFields

source ·
pub trait RecordFields: Sealed<RecordFieldsMarker> {
    // Required method
    fn record(&self, visitor: &mut dyn Visit);
}
Expand description

Extension trait implemented by types which can be recorded by a visitor.

This allows writing code that is generic over tracing_core’s span::Attributes, span::Record, and Event types. These types all provide inherent record methods that allow a visitor to record their fields, but there is no common trait representing this.

With RecordFields, we can write code like this:

use tracing_core::field::Visit;
use tracing_subscriber::field::RecordFields;

struct MyVisitor {
    // ...
}
impl Visit for MyVisitor {
    // ...
}

fn record_with_my_visitor<R>(r: R)
where
    R: RecordFields,
{
    let mut visitor = MyVisitor::new();
    r.record(&mut visitor);
}

Required Methods§

source

fn record(&self, visitor: &mut dyn Visit)

Record all the fields in self with the provided visitor.

Implementations on Foreign Types§

source§

impl<'a> RecordFields for Event<'a>

source§

fn record(&self, visitor: &mut dyn Visit)

source§

impl<'a> RecordFields for Attributes<'a>

source§

fn record(&self, visitor: &mut dyn Visit)

source§

impl<'a> RecordFields for Record<'a>

source§

fn record(&self, visitor: &mut dyn Visit)

source§

impl<'a, F> RecordFields for &'a F
where F: RecordFields,

source§

fn record(&self, visitor: &mut dyn Visit)

Implementors§