pub struct NonceManager;Expand description
Thread-safe process-wide nonce allocator keyed by (wallet, subaccount_id).
Implementations§
Source§impl NonceManager
impl NonceManager
Sourcepub fn next_nonce(
&self,
wallet: &str,
subaccount_id: u64,
) -> Result<u64, NonceError>
pub fn next_nonce( &self, wallet: &str, subaccount_id: u64, ) -> Result<u64, NonceError>
Allocates the next nonce for (wallet, subaccount_id) using the
system clock as the millisecond reference.
§Errors
Returns an error when the system clock is invalid, the timestamp cannot be encoded, or the suffix range is exhausted.
Sourcepub fn next_nonce_at(
&self,
wallet: &str,
subaccount_id: u64,
now_ms: u64,
) -> Result<u64, NonceError>
pub fn next_nonce_at( &self, wallet: &str, subaccount_id: u64, now_ms: u64, ) -> Result<u64, NonceError>
Allocates the next nonce for (wallet, subaccount_id) with an
injected now_ms, suitable for deterministic testing.
§Errors
Returns an error when the timestamp cannot be encoded or all suffixes for the current logical millisecond have been allocated.
Trait Implementations§
Source§impl Debug for NonceManager
impl Debug for NonceManager
Source§impl Default for NonceManager
impl Default for NonceManager
Source§fn default() -> NonceManager
fn default() -> NonceManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for NonceManager
impl RefUnwindSafe for NonceManager
impl Send for NonceManager
impl Sync for NonceManager
impl Unpin for NonceManager
impl UnsafeUnpin for NonceManager
impl UnwindSafe for NonceManager
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more