Skip to main content

EventWriter

Struct EventWriter 

Source
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

Source

pub fn append_event(&self, event: Event) -> Result<i64>

Append an event via the single-writer task. Returns the new event row id.

Source

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.

Source

pub fn flush(&self) -> Result<()>

Flush the writer: ensure all queued events are durable on disk.

Source

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.

Source

pub fn finish(self) -> Result<()>

Finish the writer: flush, close the channel, and join the thread.

Trait Implementations§

Source§

impl Drop for EventWriter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.