pub struct Store { /* private fields */ }
Implementations§
Source§impl Store
impl Store
Sourcepub fn seq_next<T: Serialize + 'static>(&self) -> u64
pub fn seq_next<T: Serialize + 'static>(&self) -> u64
Each object store have a u64 sequential id generator which will increment on each call. Notes:
- The first
seq_next()
call will return1
since is initialize at 0. - Also, if the object store does it exists yet, it will create it.
Sourcepub fn insert<T: Serialize + 'static>(&self, val: T) -> Result<()>
pub fn insert<T: Serialize + 'static>(&self, val: T) -> Result<()>
Insert a new value to the underlying store for this type.
Fails if it cannot call serde_json::to_value
pub fn first<T>(
&self,
filter: impl Into<Option<FilterGroups>>,
) -> Result<Option<T>>where
T: DeserializeOwned + 'static,
Sourcepub fn list<T>(&self, filter: impl Into<Option<FilterGroups>>) -> Result<Vec<T>>where
T: DeserializeOwned + 'static,
pub fn list<T>(&self, filter: impl Into<Option<FilterGroups>>) -> Result<Vec<T>>where
T: DeserializeOwned + 'static,
List all of the values for a given Type application the Filter
pub fn delete<T>(&self, filter: impl Into<FilterGroups>) -> Result<u64>where
T: DeserializeOwned + 'static,
Sourcepub fn update<T, F>(
&self,
filter: impl Into<FilterGroups>,
modifier: F,
) -> Result<u64>
pub fn update<T, F>( &self, filter: impl Into<FilterGroups>, modifier: F, ) -> Result<u64>
Update zero or more item in a type store, for a given filter_groups with the modifier function.
Some limitations:
- It will few clones to keep the API ergonomic convenient. (might try to use
Deserialize<'_>
) - For now, it will stop at first error. Eventually, we might capture the error an continue.
- Obviously, do not have commit/rollback capability. This is just a mock-store.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnwindSafe for Store
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