Struct cqrs_es::mem_store::MemStore

source ·
pub struct MemStore<A: Aggregate + Send + Sync> { /* private fields */ }
Expand description

Simple memory store useful for application development and testing purposes.

Creation and use in a constructing a CqrsFramework:

use cqrs_es::CqrsFramework;
use cqrs_es::mem_store::MemStore;

let store = MemStore::<MyAggregate>::default();
let cqrs = CqrsFramework::new(store, vec![], MyService);

Implementations§

source§

impl<A: Aggregate> MemStore<A>

source

pub fn get_events(&self) -> Arc<RwLock<HashMap<String, Vec<EventEnvelope<A>>>>>

👎Deprecated since 0.4.9: clone the MemStore instead

Get a shared copy of the events stored within the event store.

This can be used to verify the state of events that have been committed. Example of reading and displaying stored events:

let store = MemStore::<MyAggregate>::default();
//...
let all_locked_events = store.get_events();
let unlocked_events = all_locked_events.read().unwrap();
if let Some(events) = unlocked_events.get("test-aggregate-id-C450D1A") {
    for event in events {
        println!("{:?}", event);
    }
};

Trait Implementations§

source§

impl<A: Clone + Aggregate + Send + Sync> Clone for MemStore<A>

source§

fn clone(&self) -> MemStore<A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A: Debug + Aggregate + Send + Sync> Debug for MemStore<A>

source§

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

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

impl<A: Aggregate> Default for MemStore<A>

source§

fn default() -> Self

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

impl<A: Aggregate> EventStore<A> for MemStore<A>

§

type AC = MemStoreAggregateContext<A>

Provides the current state of an aggregate along with surrounding context. This is used by the CqrsFramework when loading an aggregate in order to handle incoming commands.
source§

fn load_events<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Vec<EventEnvelope<A>>, AggregateError<A::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load all events for a particular aggregate_id
source§

fn load_aggregate<'life0, 'life1, 'async_trait>( &'life0 self, aggregate_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<MemStoreAggregateContext<A>, AggregateError<A::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load aggregate at current state
source§

fn commit<'life0, 'async_trait>( &'life0 self, events: Vec<A::Event>, context: MemStoreAggregateContext<A>, metadata: HashMap<String, String> ) -> Pin<Box<dyn Future<Output = Result<Vec<EventEnvelope<A>>, AggregateError<A::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Commit new events

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for MemStore<A>

§

impl<A> Send for MemStore<A>

§

impl<A> Sync for MemStore<A>

§

impl<A> Unpin for MemStore<A>

§

impl<A> UnwindSafe for MemStore<A>

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.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.