pub trait RecordFields: Sealed<RecordFieldsMarker> {
    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§

Record all the fields in self with the provided visitor.

Implementations on Foreign Types§

Implementors§