pub struct SparseState { /* private fields */ }
Expand description
§State in which the documents are cached
Implementations§
Source§impl SparseState
impl SparseState
Sourcepub fn new_from_file(path: PathBuf) -> Result<Self, SparseError>
pub fn new_from_file(path: PathBuf) -> Result<Self, SparseError>
Create a new SparseState
from a root file
Sourcepub fn new_from_value(path: PathBuf, val: Value) -> Result<Self, SparseError>
pub fn new_from_value(path: PathBuf, val: Value) -> Result<Self, SparseError>
Create a new SparseState
from an in memory Value
Sourcepub fn get_root_path(&self) -> &PathBuf
pub fn get_root_path(&self) -> &PathBuf
Get the root path of the state, if any
pub fn get_state_file<'a>( &'a self, path: &Path, ) -> Result<&'a SparseStateFile, SparseError>
Sourcepub fn parse_root<S: DeserializeOwned + Serialize + SparsableTrait>(
&mut self,
) -> Result<S, SparseError>
pub fn parse_root<S: DeserializeOwned + Serialize + SparsableTrait>( &mut self, ) -> Result<S, SparseError>
Deserialize the root document from the state to the type S
Sourcepub fn parse_file<S: DeserializeOwned + Serialize + SparsableTrait>(
&mut self,
path: PathBuf,
) -> Result<S, SparseError>
pub fn parse_file<S: DeserializeOwned + Serialize + SparsableTrait>( &mut self, path: PathBuf, ) -> Result<S, SparseError>
Deserialize a document from the state to the type S
Sourcepub fn add_value(
&mut self,
path: PathBuf,
value: Value,
) -> Result<(), SparseError>
pub fn add_value( &mut self, path: PathBuf, value: Value, ) -> Result<(), SparseError>
Deserialize a file from the state to the type S
Sourcepub fn add_obj<S: DeserializeOwned + Serialize + SparsableTrait>(
&mut self,
path: PathBuf,
obj: &mut S,
) -> Result<(), SparseError>
pub fn add_obj<S: DeserializeOwned + Serialize + SparsableTrait>( &mut self, path: PathBuf, obj: &mut S, ) -> Result<(), SparseError>
Deserialize a file from the state to the type S
Sourcepub fn add_file(&mut self, path: PathBuf) -> Result<(), SparseError>
pub fn add_file(&mut self, path: PathBuf) -> Result<(), SparseError>
Deserialize a file from the state to the type S
Sourcepub fn save_to_disk(
&self,
format: Option<SparseFileFormat>,
) -> Result<(), SparseError>
pub fn save_to_disk( &self, format: Option<SparseFileFormat>, ) -> Result<(), SparseError>
Write all the files in the states to disks It’ll try not to modify anything until it’s sure it can open every file for writing
Trait Implementations§
Source§impl Clone for SparseState
impl Clone for SparseState
Source§fn clone(&self) -> SparseState
fn clone(&self) -> SparseState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for SparseState
impl RefUnwindSafe for SparseState
impl Send for SparseState
impl Sync for SparseState
impl Unpin for SparseState
impl UnwindSafe for SparseState
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