Struct Encoder
pub struct Encoder<W = Vec<u8>>where
W: Write,{ /* private fields */ }dial9 only.Expand description
Trace file encoder.
Writes the binary file header, registers event schemas, interns strings into a pool, and encodes events with delta-compressed timestamps.
The default type parameter (Vec<u8>) buffers everything in memory;
use Encoder::new_to to write to an arbitrary Write sink.
Implementations§
§impl<W> Encoder<W>where
W: Write,
impl<W> Encoder<W>where
W: Write,
pub fn new_to(writer: W) -> Result<Encoder<W>, Error>
pub fn new_to(writer: W) -> Result<Encoder<W>, Error>
Create an encoder that writes to an arbitrary writer. Writes the file header immediately.
pub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consume the encoder and return the inner writer.
pub fn bytes_written(&self) -> u64
pub fn bytes_written(&self) -> u64
Total bytes written through this encoder (including the file header).
pub fn reset_to(&mut self, new_writer: W) -> Result<W, Error>
pub fn reset_to(&mut self, new_writer: W) -> Result<W, Error>
Reset the encoder to a new writer, preserving internal allocations. Returns the old writer. Writes a file header to the new writer.
pub fn register_schema(
&mut self,
name: &str,
fields: Vec<FieldDef>,
) -> Result<Schema, Error>
pub fn register_schema( &mut self, name: &str, fields: Vec<FieldDef>, ) -> Result<Schema, Error>
Register a schema by name. Returns a Schema handle that can be
passed to write_event (on this or any other
encoder).
All schemas have timestamps. When writing events, the first element of
values must be FieldValue::Varint(timestamp_ns). It is extracted and
encoded in the event header (not as a regular field).
Eagerly writes the schema frame. Idempotent if the definition matches.
pub fn register_existing(
&mut self,
schema: &Schema,
) -> Result<WireTypeId, Error>
pub fn register_existing( &mut self, schema: &Schema, ) -> Result<WireTypeId, Error>
Register a pre-built Schema handle with this encoder.
Eagerly writes the schema frame (and annotation frame if annotations are present). Idempotent if the definition matches.
pub fn write_event(
&mut self,
schema: &Schema,
values: &[FieldValue],
) -> Result<(), Error>
pub fn write_event( &mut self, schema: &Schema, values: &[FieldValue], ) -> Result<(), Error>
Write an event for a schema.
The first element of values must be FieldValue::Varint(timestamp_ns)
— it is extracted and encoded in the event header, not as a regular
field. The remaining values must match the schema’s field count.
If this encoder hasn’t seen schema before, it is auto-registered
(the schema frame is written before the event).
pub fn write<T>(&mut self, event: &T) -> Result<(), Error>where
T: TraceEvent + 'static,
pub fn write<T>(&mut self, event: &T) -> Result<(), Error>where
T: TraceEvent + 'static,
Write a derived TraceEvent. Auto-registers the schema on first call for this type. Handles timestamp encoding: emits TimestampReset if needed, packs u24 delta in header.
pub fn intern_string(&mut self, s: &str) -> Result<InternedString, Error>
pub fn intern_string(&mut self, s: &str) -> Result<InternedString, Error>
Intern a string, emitting a pool frame if new. Returns an InternedString handle.
pub fn write_string_pool(&mut self, entries: &[PoolEntry]) -> Result<(), Error>
pub fn intern_stack_frames(
&mut self,
frames: &[u64],
) -> Result<InternedStackFrames, Error>
pub fn intern_stack_frames( &mut self, frames: &[u64], ) -> Result<InternedStackFrames, Error>
Intern a stack-frame vector, emitting a stack-pool frame if new.
Returns an InternedStackFrames handle.
pub fn write_stack_pool( &mut self, entries: &[StackPoolEntry], ) -> Result<(), Error>
pub fn into_raw_encoder(self) -> RawEncoder<W>
pub fn into_raw_encoder(self) -> RawEncoder<W>
Convert this encoder into a RawEncoder that only supports writing
pre-encoded bytes. The byte count is preserved so rotation decisions
remain correct.
Use this after writing any structured data (headers, segment metadata) to switch to a raw-only mode for appending pre-encoded batches.
§impl Encoder
impl Encoder
pub fn write_infallible<T>(&mut self, event: &T)where
T: TraceEvent + 'static,
pub fn intern_string_infallible(&mut self, s: &str) -> InternedString
pub fn intern_stack_frames_infallible( &mut self, frames: &[u64], ) -> InternedStackFrames
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for Encoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for Encoder<W>where
W: RefUnwindSafe,
impl<W> Send for Encoder<W>where
W: Send,
impl<W> Sync for Encoder<W>where
W: Sync,
impl<W> Unpin for Encoder<W>where
W: Unpin,
impl<W> UnsafeUnpin for Encoder<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Encoder<W>where
W: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more