pub struct FileStorage { /* private fields */ }Expand description
Raw file storage with ACID guarantees.
Holds only path and strategy; no migration or versioning state.
Higher-level wrappers (e.g. VersionedFileStorage) own the migration logic
and delegate raw IO to this struct.
Implementations§
Source§impl FileStorage
impl FileStorage
Sourcepub fn new(
path: PathBuf,
strategy: FileStorageStrategy,
) -> Result<Self, StoreError>
pub fn new( path: PathBuf, strategy: FileStorageStrategy, ) -> Result<Self, StoreError>
Create a new FileStorage and handle missing-file behavior.
CreateIfMissing: succeeds without writing when file is absent.SaveIfMissing: serializesstrategy.default_value(or{}) and writes it.ErrorIfMissing: returnsStoreErrorwhen file is absent.
Sourcepub fn read_string(&self) -> Result<String, StoreError>
pub fn read_string(&self) -> Result<String, StoreError>
Read raw file contents as a string.
Returns the content exactly as stored on disk.
Sourcepub fn write_string(&self, content: &str) -> Result<(), StoreError>
pub fn write_string(&self, content: &str) -> Result<(), StoreError>
Write content to the file atomically.
Creates parent directories as needed, writes to a temp file, syncs,
then renames atomically (with retry according to strategy.atomic_write).
Sourcepub fn strategy(&self) -> &FileStorageStrategy
pub fn strategy(&self) -> &FileStorageStrategy
Returns a reference to the storage strategy.
Auto Trait Implementations§
impl Freeze for FileStorage
impl RefUnwindSafe for FileStorage
impl Send for FileStorage
impl Sync for FileStorage
impl Unpin for FileStorage
impl UnsafeUnpin for FileStorage
impl UnwindSafe for FileStorage
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