pub struct MemoryRepository<V: RepositoryItem> {
store: Mutex<HashMap<String, V>>,
}
Expand description
A simple in-memory repository implementation. The data is only stored in memory and will not persist beyond the lifetime of the repository instance.
Primary use case is for unit and integration tests.
Fields§
§store: Mutex<HashMap<String, V>>
Trait Implementations§
Source§impl<V: RepositoryItem + Clone> Default for MemoryRepository<V>
impl<V: RepositoryItem + Clone> Default for MemoryRepository<V>
Source§impl<V: RepositoryItem + Clone> Repository<V> for MemoryRepository<V>
impl<V: RepositoryItem + Clone> Repository<V> for MemoryRepository<V>
Source§fn get<'life0, 'async_trait>(
&'life0 self,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, RepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
key: String,
) -> Pin<Box<dyn Future<Output = Result<Option<V>, RepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves an item from the repository by its key.
Source§fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<V>, RepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<V>, RepositoryError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Lists all items in the repository.
Auto Trait Implementations§
impl<V> !Freeze for MemoryRepository<V>
impl<V> RefUnwindSafe for MemoryRepository<V>
impl<V> Send for MemoryRepository<V>
impl<V> Sync for MemoryRepository<V>
impl<V> Unpin for MemoryRepository<V>where
V: Unpin,
impl<V> UnwindSafe for MemoryRepository<V>
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