pub struct JsonlWriter<W: Write> { /* private fields */ }Expand description
Writes Events as JSONL, assigning sequence numbers.
Each line is flushed as it is written: a subprocess consumer reading the stream live should see a token delta when it happens, not when a buffer happens to fill.
The writer does not police stream structure — emitting
Event::RunStarted first and Event::RunFinished last is the caller’s
contract.
Implementations§
Source§impl<W: Write> JsonlWriter<W>
impl<W: Write> JsonlWriter<W>
pub fn new(writer: W) -> Self
Sourcepub fn write(&mut self, event: Event) -> Result<u64>
pub fn write(&mut self, event: Event) -> Result<u64>
Writes one event and returns the sequence number it was given.
Sourcepub fn write_line(&mut self, line: EventLine) -> Result<usize>
pub fn write_line(&mut self, line: EventLine) -> Result<usize>
Writes one already-numbered line and returns the encoded byte count, including its newline.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Returns the underlying writer.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for JsonlWriter<W>where
W: Freeze,
impl<W> RefUnwindSafe for JsonlWriter<W>where
W: RefUnwindSafe,
impl<W> Send for JsonlWriter<W>where
W: Send,
impl<W> Sync for JsonlWriter<W>where
W: Sync,
impl<W> Unpin for JsonlWriter<W>where
W: Unpin,
impl<W> UnsafeUnpin for JsonlWriter<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for JsonlWriter<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