[][src]Struct storaget::Pack

pub struct Pack<T> where
    T: Serialize + Sized + Clone
{ /* fields omitted */ }

Pack Small FS layer around type T Pack is responsible to sync T to the filesystem.

Methods

impl<'a, T> Pack<T> where
    T: Serialize + Deserialize<'de> + Default + Sized + Clone + 'a + TryFrom + From<<T as TryFrom>::TryFrom>, 
[src]

pub fn try_load_from_path(path: PathBuf) -> PackResult<Pack<T>>[src]

pub fn try_load_or_init(path: PathBuf, file_id: &str) -> PackResult<Pack<T>>[src]

impl<'a, T> Pack<T> where
    T: Serialize + Deserialize<'de> + Default + Sized + Clone + 'a, 
[src]

pub fn from_str(buffer: &str, path: PathBuf) -> PackResult<Pack<T>>[src]

pub fn load_from_path(path: PathBuf) -> PackResult<Pack<T>>[src]

Load Pack from Path If Path is file and exists, then it tries to load then deserialize. Otherwise returns PackError.

pub fn load_or_init(path: PathBuf, file_id: &str) -> PackResult<Pack<T>>[src]

Load or init Pack from Path If Path does not exist, then it tries to create; Otherwise call Pack::load_from_path(Path).

pub fn save(&self) -> PackResult<()>[src]

Save Pack manually to FS. Returns PackError if something wrong occures.

pub fn update<F, R>(&mut self, f: F) -> PackResult<R> where
    F: FnMut(&mut T) -> R, 
[src]

Update Pack Tries to update T, if SUCCESS then tries to save to FS, if SUCCESS returns R. If Fail, then doing data T rollback to backup, then return PackError.

pub fn get<F, R>(&self, f: F) -> R where
    F: Fn(&T) -> R, 
[src]

Get(Fn) -> R Access data through closure Unmutable data access

pub fn map<F, R>(&self, f: F) -> R where
    F: Fn(&T) -> R, 
[src]

Map(Fn) -> R Syntactic sugar for Get(Fn) -> R

pub fn as_mut(&mut self) -> PackGuard<T>[src]

as_mut() -> PackGuard<'a, T> returns

pub fn into_inner(self) -> T[src]

pub fn unpack(&self) -> &T[src]

Trait Implementations

impl<T> Deref for Pack<T> where
    T: Serialize + Sized + Clone
[src]

type Target = T

The resulting type after dereferencing.

Auto Trait Implementations

impl<T> RefUnwindSafe for Pack<T> where
    T: RefUnwindSafe

impl<T> Send for Pack<T> where
    T: Send

impl<T> Sync for Pack<T> where
    T: Sync

impl<T> Unpin for Pack<T> where
    T: Unpin

impl<T> UnwindSafe for Pack<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.