Skip to main content

MemoryTable

Struct MemoryTable 

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

Source

pub fn new() -> Self

An empty table.

Source

pub fn from_records(records: impl IntoIterator<Item = T>) -> Self
where 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>

Source§

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

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

impl<T> Default for MemoryTable<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Keyed + Clone + Send> Table<T> for MemoryTable<T>

Source§

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>

The records again when the table is no longer at revision since, else None. Read more
Source§

fn put(&self, record: T) -> Result<(), SourceError>

Adds record, or replaces the one with the same Keyed::key. Read more
Source§

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

fn get(&self, key: &str) -> Result<Option<T>, SourceError>
where T: Keyed,

The record with this key, or None. Read more
Source§

fn update_one( &self, key: &str, make: &mut UpdateOne<'_, T>, ) -> Result<(), SourceError>
where T: Keyed,

Like update, for the one record with this key: make is given that record (or None) as the table holds it under its lock, and what it returns is put. Read more
Source§

fn remove(&self, key: &str) -> Result<bool, SourceError>

Removes the record with this key; true when there was one. Read more
Source§

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 more

Auto 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> 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.