pub struct EventWriter { /* private fields */ }Expand description
A handle to the single-writer task. Drop is intentional and explicit: call
EventWriter::finish to flush and join the writer thread.
Implementations§
Source§impl EventWriter
impl EventWriter
Sourcepub fn append_event(&self, event: Event) -> Result<i64>
pub fn append_event(&self, event: Event) -> Result<i64>
Append an event via the single-writer task. Returns the new event row id.
Sourcepub fn append_file_change(
&self,
event: Event,
change: FileChange,
) -> Result<i64>
pub fn append_file_change( &self, event: Event, change: FileChange, ) -> Result<i64>
Append a file_change event and attach its file_changes row in one
writer transaction (SRS §4.1 file_changes; FR-1.4). The event is
inserted first, then the file_changes row is written with
event_id = last_insert_rowid(). Returns the event row id.
The FileChange.event_id field is ignored and overwritten with the
new event’s id; callers do not need to pre-allocate it.
Sourcepub fn flush(&self) -> Result<()>
pub fn flush(&self) -> Result<()>
Flush the writer: ensure all queued events are durable on disk.
Sourcepub fn close(&mut self) -> Result<()>
pub fn close(&mut self) -> Result<()>
Close the writer without consuming it: send Finish, join the thread,
and release the handle. Subsequent append_event/flush calls fail
with StorageError::WriterClosed. For use when the writer is shared
(e.g. behind Arc<Mutex<EventWriter>>) and cannot be moved out.
Idempotent with EventWriter::finish / Drop: taking the handle
here leaves None for Drop, so a later drop does not double-join.