pub trait FormatFields<'writer> {
// Required method
fn format_fields<R: RecordFields>(
&self,
writer: Writer<'writer>,
fields: R,
) -> Result;
// Provided method
fn add_fields(
&self,
current: &'writer mut FormattedFields<Self>,
fields: &Record<'_>,
) -> Result { ... }
}
fmt
and std
only.Expand description
A type that can format a set of fields to a Writer
.
FormatFields
is primarily used in the context of fmt::Subscriber
. Each
time a span or event with fields is recorded, the subscriber will format
those fields with its associated FormatFields
implementation.
Required Methods§
Sourcefn format_fields<R: RecordFields>(
&self,
writer: Writer<'writer>,
fields: R,
) -> Result
fn format_fields<R: RecordFields>( &self, writer: Writer<'writer>, fields: R, ) -> Result
Format the provided fields
to the provided Writer
, returning a result.
Provided Methods§
Sourcefn add_fields(
&self,
current: &'writer mut FormattedFields<Self>,
fields: &Record<'_>,
) -> Result
fn add_fields( &self, current: &'writer mut FormattedFields<Self>, fields: &Record<'_>, ) -> Result
Record additional field(s) on an existing span.
By default, this appends a space to the current set of fields if it is
non-empty, and then calls self.format_fields
. If different behavior is
required, the default implementation of this method can be overridden.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.