pub struct Atomic<R: ResourceExt> { /* private fields */ }Expand description
Decorator for crash-safe whole-file writes.
For file-backed resources: write-rename pattern ensures that the target file is either the old version or the new version — never a partial write.
For in-memory resources: direct delegation (crash-safety is not applicable).
Implementations§
Source§impl<R: ResourceExt> Atomic<R>
impl<R: ResourceExt> Atomic<R>
Source§impl<R: ResourceExt> Atomic<R>
impl<R: ResourceExt> Atomic<R>
Sourcepub fn write_all_durable(&self, data: &[u8]) -> StorageResult<()>
pub fn write_all_durable(&self, data: &[u8]) -> StorageResult<()>
Write the whole payload atomically AND durably: like
ResourceExt::write_all but also sync_datas the temp file
before the atomic rename. Returns only after the bytes are
physically on disk.
Use this on explicit checkpoint paths where the caller wants
post-return durability. Per-mutation flushes should keep using
the cheaper ResourceExt::write_all (best-effort, atomic
rename only).
For memory-backed inners (no filesystem path) durability is
meaningless; the call falls back to the same passthrough as
write_all.
§Errors
Propagates filesystem errors from temp creation, write,
sync_data, rename, or the inner’s post-rename commit.
Trait Implementations§
Source§impl<R: ResourceExt> ResourceExt for Atomic<R>
impl<R: ResourceExt> ResourceExt for Atomic<R>
Source§fn write_all(&self, data: &[u8]) -> StorageResult<()>
fn write_all(&self, data: &[u8]) -> StorageResult<()>
Source§fn commit(&self, final_len: Option<u64>) -> StorageResult<()>
fn commit(&self, final_len: Option<u64>) -> StorageResult<()>
Source§fn reactivate(&self) -> StorageResult<()>
fn reactivate(&self) -> StorageResult<()>
Source§fn read_at(&self, offset: u64, buf: &mut [u8]) -> StorageResult<usize>
fn read_at(&self, offset: u64, buf: &mut [u8]) -> StorageResult<usize>
buf. Read more