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
impl EnvelopeBuilder
Sourcepub fn new(record: LnmpRecord) -> EnvelopeBuilder
pub fn new(record: LnmpRecord) -> EnvelopeBuilder
Creates a new builder with the given record
Sourcepub fn timestamp(self, ts: u64) -> EnvelopeBuilder
pub fn timestamp(self, ts: u64) -> EnvelopeBuilder
Sets the timestamp (Unix epoch milliseconds, UTC)
Sourcepub fn source(self, src: impl Into<String>) -> EnvelopeBuilder
pub fn source(self, src: impl Into<String>) -> EnvelopeBuilder
Sets the source identifier
Sourcepub fn trace_id(self, id: impl Into<String>) -> EnvelopeBuilder
pub fn trace_id(self, id: impl Into<String>) -> EnvelopeBuilder
Sets the trace ID for distributed tracing
Sourcepub fn sequence(self, seq: u64) -> EnvelopeBuilder
pub fn sequence(self, seq: u64) -> EnvelopeBuilder
Sets the sequence number
Sourcepub fn label(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> EnvelopeBuilder
pub fn label( self, key: impl Into<String>, value: impl Into<String>, ) -> EnvelopeBuilder
Adds a label (key-value pair)
Sourcepub fn build(self) -> LnmpEnvelope
pub fn build(self) -> LnmpEnvelope
Builds the envelope
Auto Trait Implementations§
impl Freeze for EnvelopeBuilder
impl RefUnwindSafe for EnvelopeBuilder
impl Send for EnvelopeBuilder
impl Sync for EnvelopeBuilder
impl Unpin for EnvelopeBuilder
impl UnwindSafe for EnvelopeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more