pub struct IdempotencyId(/* private fields */);Expand description
Unique identifier for duplicate transaction prevention.
Clients generate an IdempotencyId before their first attempt at a
transaction. If the transaction needs to be retried (e.g., network
timeout), the client reuses the same ID. The server tracks committed
IDs to return the same result for duplicate requests.
Inspired by FoundationDB’s idempotency key design.
§FCIS Pattern
This type follows the Functional Core / Imperative Shell pattern:
from_bytes(): Pure restoration from storagefrom_random_bytes(): Pure construction from bytes (pub(crate))generate(): Impure shell that invokes CSPRNG
Implementations§
Source§impl IdempotencyId
impl IdempotencyId
Sourcepub fn from_bytes(bytes: [u8; 16]) -> Self
pub fn from_bytes(bytes: [u8; 16]) -> Self
Restoration from stored bytes (pure).
Use this when loading an IdempotencyId from storage or wire protocol.
Trait Implementations§
Source§impl Clone for IdempotencyId
impl Clone for IdempotencyId
Source§fn clone(&self) -> IdempotencyId
fn clone(&self) -> IdempotencyId
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IdempotencyId
impl Debug for IdempotencyId
Source§impl<'de> Deserialize<'de> for IdempotencyId
impl<'de> Deserialize<'de> for IdempotencyId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for IdempotencyId
impl Display for IdempotencyId
Source§impl From<IdempotencyId> for [u8; 16]
impl From<IdempotencyId> for [u8; 16]
Source§fn from(id: IdempotencyId) -> Self
fn from(id: IdempotencyId) -> Self
Converts to this type from the input type.
Source§impl Hash for IdempotencyId
impl Hash for IdempotencyId
Source§impl Ord for IdempotencyId
impl Ord for IdempotencyId
Source§fn cmp(&self, other: &IdempotencyId) -> Ordering
fn cmp(&self, other: &IdempotencyId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for IdempotencyId
impl PartialEq for IdempotencyId
Source§impl PartialOrd for IdempotencyId
impl PartialOrd for IdempotencyId
Source§impl Serialize for IdempotencyId
impl Serialize for IdempotencyId
impl Copy for IdempotencyId
impl Eq for IdempotencyId
impl StructuralPartialEq for IdempotencyId
Auto Trait Implementations§
impl Freeze for IdempotencyId
impl RefUnwindSafe for IdempotencyId
impl Send for IdempotencyId
impl Sync for IdempotencyId
impl Unpin for IdempotencyId
impl UnwindSafe for IdempotencyId
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