Struct chain_impl_mockchain::accounting::account::spending::SpendingCounter
source · pub struct SpendingCounter(u32);
Expand description
Spending counter associated to an account.
every time the owner is spending from an account, the counter is incremented. A matching counter needs to be used in the spending phase to make sure we have non-replayability of a transaction.
Note that the leading LANES_BITS bits are used to codify the implicit lane.
Tuple Fields§
§0: u32
Implementations§
source§impl SpendingCounter
impl SpendingCounter
const UNLANED_MASK: u32 = 536_870_911u32
const LANED_MASK: u32 = 3_758_096_384u32
pub fn lane(self) -> usize
pub fn unlaned_counter(self) -> u32
pub fn new(lane: usize, counter: u32) -> Result<Self, Error>
pub fn zero() -> Self
sourcepub fn increment(self) -> Self
pub fn increment(self) -> Self
Increment the counter within it own lane. the lane of where this counter apply, cannot change through the incrementation procedure
if the counter bits overflow, it will automatically be wrapped, so that the lane remains identical
pub fn increment_nth(self, n: u32) -> Self
pub fn to_bytes(self) -> [u8; 4]
pub fn from_bytes(bytes: [u8; 4]) -> Self
Trait Implementations§
source§impl Arbitrary for SpendingCounter
impl Arbitrary for SpendingCounter
§type Parameters = ()
type Parameters = ()
The type of parameters that
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.§type Strategy = BoxedStrategy<SpendingCounter>
type Strategy = BoxedStrategy<SpendingCounter>
The type of
Strategy
used to generate values of type Self
.source§fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
fn arbitrary_with(args: <Self as Arbitrary>::Parameters) -> Self::Strategy
source§impl Arbitrary for SpendingCounter
impl Arbitrary for SpendingCounter
source§impl Clone for SpendingCounter
impl Clone for SpendingCounter
source§fn clone(&self) -> SpendingCounter
fn clone(&self) -> SpendingCounter
Returns a copy 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 SpendingCounter
impl Debug for SpendingCounter
source§impl From<SpendingCounter> for u32
impl From<SpendingCounter> for u32
source§fn from(v: SpendingCounter) -> u32
fn from(v: SpendingCounter) -> u32
Converts to this type from the input type.
source§impl From<u32> for SpendingCounter
impl From<u32> for SpendingCounter
source§impl PartialEq<SpendingCounter> for SpendingCounter
impl PartialEq<SpendingCounter> for SpendingCounter
source§fn eq(&self, other: &SpendingCounter) -> bool
fn eq(&self, other: &SpendingCounter) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for SpendingCounter
impl Eq for SpendingCounter
impl StructuralEq for SpendingCounter
impl StructuralPartialEq for SpendingCounter
Auto Trait Implementations§
impl RefUnwindSafe for SpendingCounter
impl Send for SpendingCounter
impl Sync for SpendingCounter
impl Unpin for SpendingCounter
impl UnwindSafe for SpendingCounter
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