Struct fixity::map::BatchMap[][src]

pub struct BatchMap<'f>(_);

Implementations

impl<'f> BatchMap<'f>[src]

pub fn new<C, W>(inner_map: BatchMap<'f, C, W>) -> Self where
    C: CacheRead + CacheWrite,
    W: Workspace
[src]

pub fn clear(&mut self)[src]

Drop the internal change cache that has not yet been staged or committed to storage.

Examples

let f = Fixity::memory();
let mut m = f.map(Path::new()).batch();
m.insert("foo", "bar");
m.clear();
assert!(m.get("foo").await.unwrap().is_none());

pub fn insert<K, V>(&mut self, key: K, value: V) where
    K: Into<Key>,
    V: Into<Value>, 
[src]

Insert a value into the map to later be staged or committed.

This value is not written to the store until Self::stage or Self::commit is called, but it can be retrived from the internal cache.

Examples

let f = Fixity::memory();
let mut m_1 = f.map(Path::new()).batch();
let m_2 = f.map(Path::new()).batch();
m_1.insert("foo", "bar");
// get pulls from in-memory cache, awaiting stage/commit.
assert_eq!(m_1.get("foo").await.unwrap(), Some("bar".into()));
// not yet written to storage.
assert_eq!(m_2.get("foo").await.unwrap(), None);

pub async fn get<K>(&self, key: K) -> Result<Option<Value>, Error> where
    K: Into<Key>, 
[src]

pub async fn stage(&mut self) -> Result<Addr, Error>[src]

Write any changes to storage, staging them for a later commit.

Examples

let f = Fixity::memory();
let mut m_1 = f.map(Path::new()).batch();
let m_2 = f.map(Path::new()).batch();
m_1.insert("foo", "bar");
// not yet written to storage.
assert_eq!(m_2.get("foo").await.unwrap(), None);
let _staged_addr = m_1.stage().await.unwrap();
// now in storage.
assert_eq!(m_2.get("foo").await.unwrap(), Some("bar".into()));

pub async fn commit(&mut self) -> Result<Addr, Error>[src]

Write any staged changes at the current [Path] into the workspace.

Examples

let f = fixity::fixity::Fixity::memory();
let mut m_1 = f.map(Path::new()).batch();
let m_2 = f.map(Path::new()).batch();
m_1.insert("foo", "bar");
// not yet written to storage.
assert_eq!(m_2.get("foo").await.unwrap(), None);
m_1.stage().await.unwrap();
m_1.commit().await.unwrap();
// now in storage.
assert_eq!(m_2.get("foo").await.unwrap(), Some("bar".into()));

Auto Trait Implementations

impl<'f> !RefUnwindSafe for BatchMap<'f>

impl<'f> !Send for BatchMap<'f>

impl<'f> !Sync for BatchMap<'f>

impl<'f> Unpin for BatchMap<'f>

impl<'f> !UnwindSafe for BatchMap<'f>

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> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

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.