Skip to main content

FileStore

Struct FileStore 

Source
pub struct FileStore { /* private fields */ }
Expand description

The spec/ tree under a directory.

Implementations§

Source§

impl FileStore

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn lock(&self) -> Result<Option<Lock>, StoreError>

The lock beside spec/, or none.

§Errors

The lock is there but cannot be read, or is not a valid lock record.

Source

pub fn publish(&self, files: Files, lock: &Lock) -> Result<(), StoreError>

Writes what a publish gives in one save: the files under spec/ it changes, and the lock beside spec/; all of them or none (AC-463).

§Errors

A file cannot be staged or put in place.

Trait Implementations§

Source§

impl Clone for FileStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DocumentStore for FileStore

Source§

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.

Source§

fn load(&self) -> Result<Document, StoreError>

The document the store holds. Read more
Source§

fn roots(&self) -> Result<Roots, StoreError>

The roots of the document the store holds. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.