pub struct AofWriter { /* private fields */ }Expand description
Buffered writer for appending AOF records to a file.
Implementations§
Source§impl AofWriter
impl AofWriter
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Self, FormatError>
pub fn open(path: impl Into<PathBuf>) -> Result<Self, FormatError>
Opens (or creates) an AOF file. If the file is new, writes the header. If the file already exists, appends to it.
Sourcepub fn write_record(&mut self, record: &AofRecord) -> Result<(), FormatError>
pub fn write_record(&mut self, record: &AofRecord) -> Result<(), FormatError>
Appends a record to the AOF.
When an encryption key is set, writes: [nonce: 12B][len: 4B][ciphertext].
Otherwise writes the v2 format: [tag+payload][crc32: 4B].
Sourcepub fn flush(&mut self) -> Result<(), FormatError>
pub fn flush(&mut self) -> Result<(), FormatError>
Flushes the internal buffer to the OS.
Sourcepub fn sync(&mut self) -> Result<(), FormatError>
pub fn sync(&mut self) -> Result<(), FormatError>
Flushes and fsyncs the file to disk.
Sourcepub fn truncate(&mut self) -> Result<(), FormatError>
pub fn truncate(&mut self) -> Result<(), FormatError>
Truncates the AOF file back to just the header.
Uses write-to-temp-then-rename for crash safety: the old AOF remains intact until the new file (with only a header) is fully synced and atomically renamed into place.
Auto Trait Implementations§
impl Freeze for AofWriter
impl RefUnwindSafe for AofWriter
impl Send for AofWriter
impl Sync for AofWriter
impl Unpin for AofWriter
impl UnsafeUnpin for AofWriter
impl UnwindSafe for AofWriter
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