pub struct WalReader { /* private fields */ }Expand description
Reads and parses a WAL file into a list of events.
Malformed lines are silently skipped. This is intentional — partial writes from crashes may leave incomplete JSON at the end of the file.
§Example
ⓘ
use runtimo_core::WalReader;
use std::path::Path;
let reader = WalReader::load(Path::new("/tmp/app.wal")).unwrap();
for event in reader.events() {
println!("Event: {:?} for job {}", event.event_type, event.job_id);
}Implementations§
Source§impl WalReader
impl WalReader
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Loads and parses all events from a WAL file.
§Errors
Returns Error::WalError if the file cannot
be read. Individual malformed lines are skipped, not treated as errors.
Sourcepub fn tail(path: &Path, n: usize) -> Result<Self>
pub fn tail(path: &Path, n: usize) -> Result<Self>
Reads only the last n lines from the WAL file.
More efficient than WalReader::load when only recent events are needed.
Malformed lines are silently skipped.
§Errors
Returns Error::WalError if the file cannot
be read.
Auto Trait Implementations§
impl Freeze for WalReader
impl RefUnwindSafe for WalReader
impl Send for WalReader
impl Sync for WalReader
impl Unpin for WalReader
impl UnsafeUnpin for WalReader
impl UnwindSafe for WalReader
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