Skip to main content

MoqTraceWriter

Struct MoqTraceWriter 

Source
pub struct MoqTraceWriter<W: Write> {
    inner: BufWriter<W>,
}
Expand description

Streaming writer for .moqtrace files.

Writes a preamble (magic, version, header) on construction, then accepts events one at a time via write_event.

For a segmented trace — on-disk capture rotation, or a live stream carried over MoQT — call start_segment to begin a new segment with a fresh preamble of its own. A plain file is one segment.

The inner writer is wrapped in a BufWriter so events can be appended at line rate without incurring one syscall per event. Call flush or into_inner to drain the buffer.

Fields§

§inner: BufWriter<W>

Implementations§

Source§

impl<W: Write> MoqTraceWriter<W>

Source

pub fn new(writer: W, header: &TraceHeader) -> Result<Self, MoqTraceError>

Create a new writer, writing the preamble and header of the file (or of its first segment).

Source

pub fn write_event(&mut self, event: &TraceEvent) -> Result<(), MoqTraceError>

Append a single event to the current segment.

Source

pub fn start_segment( &mut self, header: &TraceHeader, ) -> Result<(), MoqTraceError>

Begin a new segment, writing a fresh preamble immediately after the previous segment’s last event.

The header must carry segment metadata, and this returns an error if it does not. That field is what tells a reader the sequence numbers and timestamps it is about to see restart at zero; without it a reader takes each segment for a complete file and reconstructs a timeline that repeatedly jumps backwards.

The new header should keep the same protocol, perspective, detail and session_id as the segments before it, and increment segment.sequence.

Source

pub fn flush(&mut self) -> Result<(), MoqTraceError>

Flush the underlying writer.

Source

pub fn into_inner(self) -> Result<W, MoqTraceError>

Consume the writer and return the inner writer.

Flushes any buffered bytes. Returns an error if the flush fails.

Trait Implementations§

Source§

impl<W: Debug + Write> Debug for MoqTraceWriter<W>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for MoqTraceWriter<W>
where BufWriter<W>: Freeze,

§

impl<W> RefUnwindSafe for MoqTraceWriter<W>

§

impl<W> Send for MoqTraceWriter<W>
where BufWriter<W>: Send,

§

impl<W> Sync for MoqTraceWriter<W>
where BufWriter<W>: Sync,

§

impl<W> Unpin for MoqTraceWriter<W>
where BufWriter<W>: Unpin,

§

impl<W> UnsafeUnpin for MoqTraceWriter<W>

§

impl<W> UnwindSafe for MoqTraceWriter<W>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.