EnvelopeBuilder

Struct EnvelopeBuilder 

Source
pub struct EnvelopeBuilder { /* private fields */ }
Expand description

Fluent builder for constructing envelopes

§Example

use lnmp_core::{LnmpRecord, LnmpField, LnmpValue};
use lnmp_envelope::EnvelopeBuilder;

let mut record = LnmpRecord::new();
record.add_field(LnmpField { fid: 12, value: LnmpValue::Int(14532) });

let envelope = EnvelopeBuilder::new(record)
    .timestamp(1732373147000)
    .source("auth-service")
    .trace_id("abc-123-xyz")
    .sequence(42)
    .build();

Implementations§

Source§

impl EnvelopeBuilder

Source

pub fn new(record: LnmpRecord) -> EnvelopeBuilder

Creates a new builder with the given record

Source

pub fn timestamp(self, ts: u64) -> EnvelopeBuilder

Sets the timestamp (Unix epoch milliseconds, UTC)

Source

pub fn source(self, src: impl Into<String>) -> EnvelopeBuilder

Sets the source identifier

Source

pub fn trace_id(self, id: impl Into<String>) -> EnvelopeBuilder

Sets the trace ID for distributed tracing

Source

pub fn sequence(self, seq: u64) -> EnvelopeBuilder

Sets the sequence number

Source

pub fn label( self, key: impl Into<String>, value: impl Into<String>, ) -> EnvelopeBuilder

Adds a label (key-value pair)

Source

pub fn build(self) -> LnmpEnvelope

Builds the envelope

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.