Struct JournalWriter
pub struct JournalWriter { /* private fields */ }Expand description
Append-only journal writer.
The writer stamps each event with monotonically increasing seq,
a fresh event_id, mono_ns elapsed since mono_origin, the
current wall-clock ts_utc, and the writer’s run_id.
Implementations§
§impl JournalWriter
impl JournalWriter
pub fn append(
&mut self,
event: EngineEvent,
) -> Result<EngineEvent, JournalError>
pub fn append( &mut self, event: EngineEvent, ) -> Result<EngineEvent, JournalError>
Append an event to the journal.
The writer overwrites the event’s seq, event_id, mono_ns,
ts_utc, and run_id fields, then returns the finalized event.
pub fn stamp(
&mut self,
event: EngineEvent,
) -> Result<(EngineEvent, Vec<u8>), JournalError>
pub fn stamp( &mut self, event: EngineEvent, ) -> Result<(EngineEvent, Vec<u8>), JournalError>
Stamp envelope fields, compute hash chain, and serialize to frame bytes.
Performs no disk I/O and does not mutate internal chain state.
Returns (stamped_event, length_prefixed_frame_bytes).
pub fn write_frame(&mut self, frame: &[u8]) -> Result<(), JournalError>
pub fn write_frame(&mut self, frame: &[u8]) -> Result<(), JournalError>
Write pre-serialized frame bytes to the journal file.
Writes the frame and optionally fsyncs according to the configured
FsyncPolicy.
pub fn sync(&mut self) -> Result<(), JournalError>
pub fn sync(&mut self) -> Result<(), JournalError>
Explicitly fsync the journal file.
pub fn fsync_policy(&self) -> FsyncPolicy
pub fn fsync_policy(&self) -> FsyncPolicy
Return the configured fsync policy.
pub fn last_record_hash(&self) -> Option<&str>
pub fn last_record_hash(&self) -> Option<&str>
Return the last record hash (for chain verification after close).
pub fn try_clone_file(&self) -> Result<File, JournalError>
pub fn try_clone_file(&self) -> Result<File, JournalError>
Clone the underlying file descriptor.
Used by super::async_writer::AsyncJournalWriter to hand an
independent fd to the background write thread.