pub struct MemoryStore { /* private fields */ }Expand description
A resource store backed by an ordered list of items.
Items keep the order they were created in, which is the order the collection
lists them in when no sort is asked for.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn with_id_field<S: Into<String>>(id_field: S) -> Self
pub fn with_id_field<S: Into<String>>(id_field: S) -> Self
An empty store whose identifier field has another name.
Sourcepub fn seeded<I: IntoIterator<Item = LinoValue>>(items: I) -> Self
pub fn seeded<I: IntoIterator<Item = LinoValue>>(items: I) -> Self
A store seeded with items.
§Examples
use lino_rest_api::store::MemoryStore;
use lino_rest_api::value::{get, int, object, string};
let store = MemoryStore::seeded([object([("title", string("Ship it"))])]);
assert_eq!(get(&store.read("1").unwrap(), "id"), Some(&int(1)));Sourcepub fn insert(&self, body: &LinoValue) -> LinoValue
pub fn insert(&self, body: &LinoValue) -> LinoValue
Create an item without awaiting, for seeding and for tests.
Trait Implementations§
Source§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§fn default() -> MemoryStore
fn default() -> MemoryStore
Returns the “default value” for a type. Read more
Source§impl Store for MemoryStore
impl Store for MemoryStore
Source§fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 CollectionQuery,
) -> Pin<Box<dyn Future<Output = Result<LinoValue, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 CollectionQuery,
) -> Pin<Box<dyn Future<Output = Result<LinoValue, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run a collection query, returning a collection envelope.
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<LinoValue>, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<LinoValue>, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read one item, or
None when it does not exist.Source§fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
body: &'life1 LinoValue,
) -> Pin<Box<dyn Future<Output = Result<LinoValue, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
body: &'life1 LinoValue,
) -> Pin<Box<dyn Future<Output = Result<LinoValue, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create an item, assigning an identifier when the body carries none.
Source§fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
body: &'life2 LinoValue,
) -> Pin<Box<dyn Future<Output = Result<Option<LinoValue>, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
body: &'life2 LinoValue,
) -> Pin<Box<dyn Future<Output = Result<Option<LinoValue>, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Replace an item, or
None when it does not exist.Source§fn patch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
body: &'life2 LinoValue,
) -> Pin<Box<dyn Future<Output = Result<Option<LinoValue>, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn patch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
identifier: &'life1 str,
body: &'life2 LinoValue,
) -> Pin<Box<dyn Future<Output = Result<Option<LinoValue>, LinoHttpError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Merge changes into an item, or
None when it does not exist.Auto Trait Implementations§
impl !Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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