Skip to content

Commit

Permalink
make the AggregateManager deref blanket implementation work for smart…
Browse files Browse the repository at this point in the history
… pointers (#187)

* Update dockerfile rust image to 1.75

* Refactor common to avoid having to publicly expose event_handlers with pub use

* make the AggregateManager deref blanket implementation work for all smart pointers

* Fix documentation

---------

Co-authored-by: Simone Cottini <cottini.simone@gmail.com>
  • Loading branch information
angelo-rendina-prima and cottinisimone authored Feb 12, 2024
1 parent b0e27f3 commit 04c87d8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ pub trait EventStore {
async fn delete(&self, aggregate_id: Uuid) -> Result<(), Self::Error>;
}

/// Default generic implementation for every type implementing [`Deref`] where its `Target` is a
/// `dyn` [`EventStore`]. This is particularly useful when there's the need in your codebase to have
/// a generic [`EventStore`].
/// Blanket implementation making an [`EventStore`] every (smart) pointer to an [`EventStore`],
/// e.g. `&Store`, `Box<Store>`, `Arc<Store>`.
/// This is particularly useful when there's the need in your codebase to have a generic [`EventStore`].
#[async_trait]
impl<A, E, T> EventStore for T
impl<A, E, T, S> EventStore for T
where
A: crate::Aggregate,
A::Event: Send + Sync,
A::State: Send,
E: std::error::Error,
T: Deref<Target = dyn EventStore<Aggregate = A, Error = E> + Sync> + Sync,
S: EventStore<Aggregate = A, Error = E> + ?Sized,
T: Deref<Target = S> + Sync,
for<'a> A::Event: 'a,
{
type Aggregate = A;
Expand Down

0 comments on commit 04c87d8

Please sign in to comment.