Skip to main content

RecordLogWriter

Struct RecordLogWriter 

Source
pub struct RecordLogWriter { /* private fields */ }
Expand description

Append-only record log writer.

Implementations§

Source§

impl RecordLogWriter

Source

pub fn new(dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>) -> Self

Create a record log writer that appends to path.

Source

pub fn new_conservative( dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>, ) -> Self

Conservative default: no buffering + flush after each append.

Source

pub fn with_flush_policy( dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>, flush_policy: FlushPolicy, ) -> Self

Create a record log writer with an explicit flush policy.

Source

pub fn with_options( dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>, flush_policy: FlushPolicy, write_buffer_limit_bytes: usize, ) -> Self

Create a record log writer with explicit flush policy and write buffer size.

write_buffer_limit_bytes == 0 disables buffering (writes are issued on each append).

Source

pub fn flush(&mut self) -> PersistenceResult<()>

Flush the underlying writer (if one is open).

Source

pub fn flush_and_sync(&mut self) -> PersistenceResult<()>

Flush buffered bytes and attempt to make the record log durable on stable storage.

This is an opt-in stronger guarantee than flush():

  • flush() is a visibility boundary (userspace → OS / underlying writer).
  • flush_and_sync() additionally calls sync_all on the underlying file.

Returns NotSupported if the underlying Directory does not provide file_path().

Source

pub fn append_bytes(&mut self, payload: &[u8]) -> PersistenceResult<()>

Append one record containing payload.

Source

pub fn append_postcard<T: Serialize>( &mut self, value: &T, ) -> PersistenceResult<()>

Append one postcard-encoded value as a record payload.

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<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, 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.