From 8ab3e7b0296f89b237d881b77f6f446270e0be65 Mon Sep 17 00:00:00 2001 From: Angelo Date: Tue, 7 May 2024 15:09:56 +0200 Subject: [PATCH] docs and is_some --- src/manager.rs | 3 +-- src/manager/locked_load.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/manager.rs b/src/manager.rs index d2286a3..9a29289 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -75,8 +75,7 @@ where /// Acquires a lock on this aggregate instance, and only then loads it from the event store, /// by applying previously persisted events onto the aggregate state by order of their sequence number. /// - /// The lock is contained in the returned `AggregateState`, and released when this is dropped. - /// It can also be extracted with the `take_lock` method for more advanced uses. + /// The returned [`LockedLoad`] contains the outcome of the load and is responsible for correctly managing the lock. pub async fn lock_and_load( &self, aggregate_id: impl Into + Send, diff --git a/src/manager/locked_load.rs b/src/manager/locked_load.rs index 86310c8..17a5ec1 100644 --- a/src/manager/locked_load.rs +++ b/src/manager/locked_load.rs @@ -23,6 +23,15 @@ impl LockedLoad { Self(LockedLoadInner::None { id, lock }) } + /// Checks if the AggregateState was found. + pub fn is_some(&self) -> bool { + let Self(inner) = self; + match inner { + LockedLoadInner::None { .. } => false, + LockedLoadInner::Some(_) => true, + } + } + /// Extracts the contained AggregateState, or panics otherwise. pub fn unwrap(self) -> AggregateState { let Self(inner) = self;