pub struct MoqTraceWriter<W: Write> {
inner: BufWriter<W>,
}Expand description
Streaming writer for .moqtrace files.
Writes the preamble (magic, version, header) on construction, then
accepts events one at a time via write_event.
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>
impl<W: Write> MoqTraceWriter<W>
Sourcepub fn new(writer: W, header: &TraceHeader) -> Result<Self, MoqTraceError>
pub fn new(writer: W, header: &TraceHeader) -> Result<Self, MoqTraceError>
Create a new writer, writing the file preamble and header.
Sourcepub fn write_event(&mut self, event: &TraceEvent) -> Result<(), MoqTraceError>
pub fn write_event(&mut self, event: &TraceEvent) -> Result<(), MoqTraceError>
Append a single event to the file.
Sourcepub fn flush(&mut self) -> Result<(), MoqTraceError>
pub fn flush(&mut self) -> Result<(), MoqTraceError>
Flush the underlying writer.
Sourcepub fn into_inner(self) -> Result<W, MoqTraceError>
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§
Auto Trait Implementations§
impl<W> Freeze for MoqTraceWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for MoqTraceWriter<W>where
W: RefUnwindSafe,
impl<W> Send for MoqTraceWriter<W>where
W: Send,
impl<W> Sync for MoqTraceWriter<W>where
W: Sync,
impl<W> Unpin for MoqTraceWriter<W>where
W: Unpin,
impl<W> UnsafeUnpin for MoqTraceWriter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for MoqTraceWriter<W>where
W: UnwindSafe,
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