Skip to main content

FieldEncoder

Struct FieldEncoder 

Source
pub struct FieldEncoder<'a> { /* private fields */ }
Expand description

Encoder for adding key-value fields and span information to a log entry.

Created by Encoder::append or FieldBuffer::encoder. When dropped, the log entry is finalized with the correct length header.

Implementations§

Source§

impl<'a> FieldEncoder<'a>

Source

pub fn fields(self) -> LogFields<'a>

Converts this encoder into an iterator over the encoded fields.

Consumes the encoder without finalizing the log entry header.

Source

pub fn start_span(self, span: SpanID)

Encodes a span start marker for the given span ID.

Consumes the encoder to finalize the log entry.

Source

pub fn start_span_with_parent(self, span: SpanID, parent: Option<SpanID>)

Encodes a span start marker with an optional parent span.

Consumes the encoder to finalize the log entry.

Source

pub fn apply_span(self, span: SpanID)

Associates this log entry with an active span.

Consumes the encoder to finalize the log entry.

Source

pub fn end_span(self, span: SpanID)

Encodes a span end marker for the given span ID.

Consumes the encoder to finalize the log entry.

Source

pub fn apply_span_info(self, info: SpanInfo)

Applies the given span information to this log entry.

Consumes the encoder to finalize the log entry.

Source

pub fn apply_current_span(self)

Associates this log entry with the current thread-local span, if any.

Consumes the encoder to finalize the log entry.

Source

pub fn key(&mut self, key: &str) -> ValueEncoder<'_>

Begins encoding a field with the given key name.

If the key matches a known static key, uses the compact single-byte encoding. Returns a ValueEncoder for encoding the field value.

§Panics

Panics if the key exceeds 127 bytes.

Source

pub fn dynamic_key(&mut self, key: &str) -> ValueEncoder<'_>

Begins encoding a field with a dynamic key name.

Unlike key, this always uses the length-prefixed encoding even for known static keys.

§Panics

Panics if the key exceeds 127 bytes.

Source

pub fn static_key(&mut self, key: StaticKey) -> ValueEncoder<'_>

Begins encoding a field with a known static key.

Uses the compact single-byte encoding for the key.

Trait Implementations§

Source§

impl<'a> Drop for FieldEncoder<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for FieldEncoder<'a>

§

impl<'a> Freeze for FieldEncoder<'a>

§

impl<'a> RefUnwindSafe for FieldEncoder<'a>

§

impl<'a> Send for FieldEncoder<'a>

§

impl<'a> Sync for FieldEncoder<'a>

§

impl<'a> Unpin for FieldEncoder<'a>

§

impl<'a> UnsafeUnpin for FieldEncoder<'a>

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.