pub struct EventCollector<E> { /* private fields */ }Expand description
A projector that collects events for testing assertions.
EventCollector stores events in shared, thread-safe storage (Arc<Mutex<Vec<E>>>)
so that events can be inspected after projection completes. This is the primary
mechanism for black-box integration testing in EventCore.
§Type Parameters
E: The event type to collect. Must beCloneso thatevents()can return owned copies without consuming the collector.
§Thread Safety
The internal storage uses Arc<Mutex<_>> to allow the collector to be shared
across threads (e.g., between the projection runner and test assertions).
Implementations§
Source§impl<E> EventCollector<E>
impl<E> EventCollector<E>
Sourcepub fn new(storage: Arc<Mutex<Vec<E>>>) -> Self
pub fn new(storage: Arc<Mutex<Vec<E>>>) -> Self
Creates a new EventCollector with the provided shared storage.
§Arguments
storage- AnArc<Mutex<Vec<E>>>that will hold collected events. The same storage can be cloned before passing to enable access to collected events after the collector is moved.
Trait Implementations§
Source§impl<E: Debug> Debug for EventCollector<E>
impl<E: Debug> Debug for EventCollector<E>
Source§impl<E: Send + 'static> Projector for EventCollector<E>
impl<E: Send + 'static> Projector for EventCollector<E>
Source§type Error = Infallible
type Error = Infallible
The error type returned when projection fails.
Source§fn apply(
&mut self,
event: Self::Event,
_position: StreamPosition,
_ctx: &mut Self::Context,
) -> Result<(), Self::Error>
fn apply( &mut self, event: Self::Event, _position: StreamPosition, _ctx: &mut Self::Context, ) -> Result<(), Self::Error>
Process a single event and update the read model. Read more
Source§fn on_error(&mut self, _ctx: FailureContext<'_, Self::Error>) -> FailureStrategy
fn on_error(&mut self, _ctx: FailureContext<'_, Self::Error>) -> FailureStrategy
Handle event processing errors and determine failure strategy. Read more
Auto Trait Implementations§
impl<E> Freeze for EventCollector<E>
impl<E> RefUnwindSafe for EventCollector<E>
impl<E> Send for EventCollector<E>where
E: Send,
impl<E> Sync for EventCollector<E>where
E: Send,
impl<E> Unpin for EventCollector<E>
impl<E> UnsafeUnpin for EventCollector<E>
impl<E> UnwindSafe for EventCollector<E>
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