Skip to main content

FieldCapture

Struct FieldCapture 

Source
pub struct FieldCapture {
    pub scratch: BytesMut,
    /* private fields */
}
Expand description

Visitor used by tracing’s Event::record(visitor) to extract typed values into a thread-local scratch space; reused across emissions (zero per-event allocation in the steady state). Spec 12 § 3.6.

The tracing::field::Visit impl lives in obs-tracing-bridge (Phase 4B) so obs-core does not pull in the tracing crate. The type lives here because the bridge’s register_typed::<E>(...) closure receives &mut FieldCapture and a closure that returns E: EventSchema belongs to the schema layer.

Fields§

§scratch: BytesMut

Reused encoder scratch for record_debug / record_display.

Implementations§

Source§

impl FieldCapture

Source

pub fn new() -> FieldCapture

Empty capture with default capacities.

Source

pub fn clear(&mut self)

Reset all sub-vectors but preserve their capacity. The bridge calls this between events to keep the steady state allocation- free. Spec 12 § 3.6.

Source

pub fn len(&self) -> usize

Total number of recorded fields.

Source

pub fn is_empty(&self) -> bool

True if no field has been recorded.

Source

pub fn record_str(&mut self, name: &'static str, value: impl Into<String>)

Record a string field.

Source

pub fn record_u64(&mut self, name: &'static str, value: u64)

Record a u64 field.

Source

pub fn record_i64(&mut self, name: &'static str, value: i64)

Record an i64 field.

Source

pub fn record_f64(&mut self, name: &'static str, value: f64)

Record an f64 field.

Source

pub fn record_bool(&mut self, name: &'static str, value: bool)

Record a bool field.

Source

pub fn string(&self, name: &str) -> Option<&str>

Look up a string field by name; returns the last record (so later writes shadow earlier ones, matching tracing’s own Visit semantics).

Source

pub fn u64(&self, name: &str) -> Option<u64>

Look up a u64 field by name.

Source

pub fn i64(&self, name: &str) -> Option<i64>

Look up an i64 field by name.

Source

pub fn f64(&self, name: &str) -> Option<f64>

Look up an f64 field by name.

Source

pub fn bool(&self, name: &str) -> Option<bool>

Look up a bool field by name.

Source

pub fn duration(&self, name: &str) -> Option<Duration>

Look up a u64 field that should be interpreted as nanoseconds.

Source

pub fn iter_strings(&self) -> impl Iterator<Item = (&'static str, &str)>

Iterator of all recorded string fields. Used by promotion paths that walk every field looking for known label names.

Trait Implementations§

Source§

impl Debug for FieldCapture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for FieldCapture

Source§

fn default() -> FieldCapture

Returns the “default value” for a type. Read more

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.