pub struct FileStore { /* private fields */ }Expand description
The spec/ tree under a directory.
Implementations§
Source§impl FileStore
impl FileStore
Sourcepub fn open(root: &Path) -> Result<Self, StoreError>
pub fn open(root: &Path) -> Result<Self, StoreError>
The store of the tree under root, after finishing a committed save there that was
interrupted, or discarding an uncommitted one.
§Errors
An interrupted save that cannot be recovered.
Sourcepub fn read_files(&self) -> Result<Files, StoreError>
pub fn read_files(&self) -> Result<Files, StoreError>
Every file of the tree, by its path under spec/.
§Errors
A missing spec/ directory, a file that cannot be read, or a name that is not UTF-8.
Sourcepub fn write_files(&self, files: Files) -> Result<(), StoreError>
pub fn write_files(&self, files: Files) -> Result<(), StoreError>
Writes the given files of the tree in one save and removes none.
§Errors
A file that cannot be staged or put in place.
Sourcepub fn import(&self, files: Files, sidecar: &[u8]) -> Result<(), StoreError>
pub fn import(&self, files: Files, sidecar: &[u8]) -> Result<(), StoreError>
Writes an imported tree into an empty or missing spec/, and the sidecar beside it, in
one save.
§Errors
spec/ holds a file or directory already (RQ-134), in which case nothing is written; or a
file cannot be written.
Sourcepub fn create(&self, files: Files) -> Result<(), StoreError>
pub fn create(&self, files: Files) -> Result<(), StoreError>
Writes a new tree into a spec/ that does not exist yet, in one save.
§Errors
spec/ exists already, in which case nothing is written; or a file cannot be written.
Trait Implementations§
Source§impl DocumentStore for FileStore
impl DocumentStore for FileStore
Source§fn save(&mut self, document: &Document) -> Result<Saved, StoreError>
fn save(&mut self, document: &Document) -> Result<Saved, StoreError>
Writes each file whose bytes change and removes each file the document no longer has, in one save; a file whose bytes would not change is left alone. A save of this store’s that failed part-way is finished first, so the tree it compares against is the one it left.