pub trait IdempotencyStorageProvider {
// Required method
fn try_reserve<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 IdempotencyToken,
) -> Pin<Box<dyn Future<Output = Result<bool, OutboxError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Async contract for reserving an idempotency token before an event is written.
The implementation is expected to perform an atomic “claim if absent”
operation (e.g. SET NX in Redis) so concurrent producers cannot both
reserve the same token.
Required Methods§
Sourcefn try_reserve<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 IdempotencyToken,
) -> Pin<Box<dyn Future<Output = Result<bool, OutboxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_reserve<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 IdempotencyToken,
) -> Pin<Box<dyn Future<Output = Result<bool, OutboxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attempts to reserve token as unused.
Returns true if the token has been reserved by this call and the
event may proceed, or false if the token was already taken — in
which case OutboxService::add_event
surfaces a DuplicateEvent.
§Errors
Returns an OutboxError — typically
InfrastructureError — when the
reservation backend itself fails (connection lost, timeout, etc.).
The error is propagated to the caller without inserting the event.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".