pub struct JsonlReader<T> { /* private fields */ }Expand description
Reads JSONL records from a file, tracking the byte offset so that each poll only returns lines appended since the previous read.
Generic over any T: DeserializeOwned.
Implementations§
Source§impl<T: DeserializeOwned> JsonlReader<T>
impl<T: DeserializeOwned> JsonlReader<T>
Sourcepub fn new(path: impl Into<PathBuf>) -> Self
pub fn new(path: impl Into<PathBuf>) -> Self
Create a new reader for the given path, starting at byte offset 0.
Sourcepub fn with_offset(path: impl Into<PathBuf>, offset: u64) -> Self
pub fn with_offset(path: impl Into<PathBuf>, offset: u64) -> Self
Create a new reader starting at the given byte offset.
Useful when restoring from persisted state — you can resume reading from where you left off without replaying old messages.
Sourcepub fn set_offset(&mut self, offset: u64)
pub fn set_offset(&mut self, offset: u64)
Set the byte offset (e.g. when restoring from persisted state).
Sourcepub fn skip_to_end(&mut self) -> Result<u64>
pub fn skip_to_end(&mut self) -> Result<u64>
Skip to the end of the file so that subsequent polls only see new data.
Returns the new offset, or 0 if the file does not exist.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for JsonlReader<T>
impl<T> RefUnwindSafe for JsonlReader<T>where
T: RefUnwindSafe,
impl<T> Send for JsonlReader<T>where
T: Send,
impl<T> Sync for JsonlReader<T>where
T: Sync,
impl<T> Unpin for JsonlReader<T>where
T: Unpin,
impl<T> UnsafeUnpin for JsonlReader<T>
impl<T> UnwindSafe for JsonlReader<T>where
T: 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