SparseRoot

Struct SparseRoot 

Source
pub struct SparseRoot<S: DeserializeOwned + Serialize + SparsableTrait> { /* private fields */ }
Expand description

§A structure to hold the root document as well as its state.

Implementations§

Source§

impl<S: DeserializeOwned + Serialize + SparsableTrait> SparseRoot<S>

Source

pub fn state(&self) -> &Rc<RefCell<SparseState>>

Source

pub fn metadata(&self) -> &SparseMetadata

Source§

impl<S> SparseRoot<S>

Source

pub fn check_version(&self) -> Result<(), SparseError>

Get the value this selector is managing, either by deserializing the pointed value or by directly returning the owned value.

Source

pub fn root_get(&self) -> Result<SparseValue<'_, S>, SparseError>

Get the value this selector is managing, either by deserializing the pointed value or by directly returning the owned value.

Source

pub fn root_get_mut(&mut self) -> Result<SparseValueMut<'_, S>, SparseError>

Like root_get but return a mutable reference

Source

pub fn root_self_reset(&mut self) -> Result<(), SparseError>

Reset the root object in case of initialization or update

Source

pub fn sparse_init(&mut self) -> Result<(), SparseError>

Intitialize the inner state

Source

pub fn sparse_updt(&mut self) -> Result<(), SparseError>

Update the inner state

Source

pub fn new_from_file(path: PathBuf) -> Result<Self, SparseError>

Create a new SparseRoot from file path

Source

pub fn new_from_value( rval: Value, path: PathBuf, others: Vec<(Value, PathBuf)>, ) -> Result<Self, SparseError>

Create a new SparseRoot from a Value object

Source

pub fn new_from_obj( rval: S, path: PathBuf, others: Vec<(&mut S, PathBuf)>, ) -> Result<Self, SparseError>

Create a new SparseRoot from a serialized object

Source

pub fn save_to_disk( &self, format: Option<SparseFileFormat>, ) -> Result<(), SparseError>

Save the state to disk in the specified format. If not format is specified, the format in which the document was read will be used. If the document was read from memory, it’ll be written in prettified JSON

Trait Implementations§

Source§

impl<S: Debug + DeserializeOwned + Serialize + SparsableTrait> Debug for SparseRoot<S>

Source§

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

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

impl<S> Display for SparseRoot<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for SparseRoot<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for SparseRoot<S>

§

impl<S> !Send for SparseRoot<S>

§

impl<S> !Sync for SparseRoot<S>

§

impl<S> Unpin for SparseRoot<S>
where S: Unpin,

§

impl<S> !UnwindSafe for SparseRoot<S>

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V