pub struct MemoryTable<T> { /* private fields */ }Expand description
A table kept in memory, built in code. It is writable and its revision counts the changes made to it.
Implementations§
Source§impl<T> MemoryTable<T>
impl<T> MemoryTable<T>
Sourcepub fn from_records(records: impl IntoIterator<Item = T>) -> Selfwhere
T: Keyed,
pub fn from_records(records: impl IntoIterator<Item = T>) -> Selfwhere
T: Keyed,
A table holding records, in this order. A key given twice keeps its last record.
Trait Implementations§
Source§impl<T> Debug for MemoryTable<T>
impl<T> Debug for MemoryTable<T>
Source§impl<T> Default for MemoryTable<T>
impl<T> Default for MemoryTable<T>
Source§impl<T: Keyed + Clone + Send> Table<T> for MemoryTable<T>
impl<T: Keyed + Clone + Send> Table<T> for MemoryTable<T>
Source§fn load(&self) -> Result<Snapshot<T>, SourceError>
fn load(&self) -> Result<Snapshot<T>, SourceError>
Every record, with the revision they are at. Read more
Source§fn changes_since(
&self,
since: Revision,
) -> Result<Option<Snapshot<T>>, SourceError>
fn changes_since( &self, since: Revision, ) -> Result<Option<Snapshot<T>>, SourceError>
Source§fn update(&self, make: &mut Update<'_, T>) -> Result<(), SourceError>
fn update(&self, make: &mut Update<'_, T>) -> Result<(), SourceError>
Reads the records, lets
make decide from them what to put (None puts nothing),
and puts it. Read moreSource§fn get(&self, key: &str) -> Result<Option<T>, SourceError>where
T: Keyed,
fn get(&self, key: &str) -> Result<Option<T>, SourceError>where
T: Keyed,
The record with this key, or
None. Read moreSource§fn update_one(
&self,
key: &str,
make: &mut UpdateOne<'_, T>,
) -> Result<(), SourceError>where
T: Keyed,
fn update_one(
&self,
key: &str,
make: &mut UpdateOne<'_, T>,
) -> Result<(), SourceError>where
T: Keyed,
Source§fn remove(&self, key: &str) -> Result<bool, SourceError>
fn remove(&self, key: &str) -> Result<bool, SourceError>
Removes the record with this key;
true when there was one. Read moreSource§fn remove_where(
&self,
condition: &mut dyn FnMut(&T) -> bool,
) -> Result<usize, SourceError>
fn remove_where( &self, condition: &mut dyn FnMut(&T) -> bool, ) -> Result<usize, SourceError>
Removes every record
condition holds for, and answers how many went. Read moreAuto Trait Implementations§
impl<T> !Freeze for MemoryTable<T>
impl<T> RefUnwindSafe for MemoryTable<T>
impl<T> Send for MemoryTable<T>where
T: Send,
impl<T> Sync for MemoryTable<T>where
T: Send,
impl<T> Unpin for MemoryTable<T>where
T: Unpin,
impl<T> UnsafeUnpin for MemoryTable<T>
impl<T> UnwindSafe for MemoryTable<T>
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