pub struct RecordLogWriter { /* private fields */ }Expand description
Append-only record log writer.
Implementations§
Source§impl RecordLogWriter
impl RecordLogWriter
Sourcepub fn new(dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>) -> Self
pub fn new(dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>) -> Self
Create a record log writer that appends to path.
Sourcepub fn new_conservative(
dir: impl Into<Arc<dyn Directory>>,
path: impl Into<String>,
) -> Self
pub fn new_conservative( dir: impl Into<Arc<dyn Directory>>, path: impl Into<String>, ) -> Self
Conservative default: no buffering + flush after each append.
Sourcepub fn with_flush_policy(
dir: impl Into<Arc<dyn Directory>>,
path: impl Into<String>,
flush_policy: FlushPolicy,
) -> Self
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.
Sourcepub fn with_options(
dir: impl Into<Arc<dyn Directory>>,
path: impl Into<String>,
flush_policy: FlushPolicy,
write_buffer_limit_bytes: usize,
) -> Self
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).
Sourcepub fn flush(&mut self) -> PersistenceResult<()>
pub fn flush(&mut self) -> PersistenceResult<()>
Flush the underlying writer (if one is open).
Sourcepub fn flush_and_sync(&mut self) -> PersistenceResult<()>
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 callssync_allon the underlying file.
Returns NotSupported if the underlying Directory does not provide file_path().
Sourcepub fn append_bytes(&mut self, payload: &[u8]) -> PersistenceResult<()>
pub fn append_bytes(&mut self, payload: &[u8]) -> PersistenceResult<()>
Append one record containing payload.
Sourcepub fn append_postcard<T: Serialize>(
&mut self,
value: &T,
) -> PersistenceResult<()>
pub fn append_postcard<T: Serialize>( &mut self, value: &T, ) -> PersistenceResult<()>
Append one postcard-encoded value as a record payload.
Auto Trait Implementations§
impl Freeze for RecordLogWriter
impl !RefUnwindSafe for RecordLogWriter
impl !Send for RecordLogWriter
impl !Sync for RecordLogWriter
impl Unpin for RecordLogWriter
impl UnsafeUnpin for RecordLogWriter
impl !UnwindSafe for RecordLogWriter
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