pub struct Version(/* private fields */);Implementations§
Source§impl Version
impl Version
Sourcepub const MIN_VALID_INCL: Self
pub const MIN_VALID_INCL: Self
An inclusive lower limit on a valid version.
A valid version means an object, which this version is assigned to, does not appear in a canceled transaction.
Sourcepub const INITIAL_SHARED_VERSION: Self
pub const INITIAL_SHARED_VERSION: Self
The initial shared version for shared system objects.
Sourcepub const MAX_VALID_EXCL: Self
pub const MAX_VALID_EXCL: Self
An exclusive upper limit on a valid version: versions strictly smaller than this limit are valid versions.
A valid version means an object, which this version is assigned to, does not appear in a canceled transaction. Versions larger than this value are “special” and assigned to objects that appear in canceled transactions.
Sourcepub const CANCELED_READ: Self
pub const CANCELED_READ: Self
Special version that is assigned to objects which are accessed immutably in a canceled transaction.
Sourcepub const CONGESTED_PRIOR_TO_GAS_PRICE_FEEDBACK: Self
pub const CONGESTED_PRIOR_TO_GAS_PRICE_FEEDBACK: Self
Special version that was assigned to congested objects which cause transaction cancellations. Note that this special version was only used prior to the introduction of a gas price feedback mechanism, but it is kept for backward compatibility.
pub const RANDOMNESS_UNAVAILABLE: Self
pub const OBJECT_START: Self
Sourcepub fn next(self) -> Result<Self, VersionError>
pub fn next(self) -> Result<Self, VersionError>
Returns the next version, or an error if overflow occurs.
Sourcepub fn increment(&mut self) -> Result<(), VersionError>
pub fn increment(&mut self) -> Result<(), VersionError>
Increments this version by one, or returns an error if overflow occurs.
Sourcepub fn previous(self) -> Result<Self, VersionError>
pub fn previous(self) -> Result<Self, VersionError>
Returns the previous version, or an error if underflow occurs.
Sourcepub fn decrement(&mut self) -> Result<(), VersionError>
pub fn decrement(&mut self) -> Result<(), VersionError>
Decrements this version by one, or returns an error if underflow occurs.
Sourcepub fn new_congested_with_suggested_gas_price(
suggested_gas_price: u64,
) -> Result<Self, VersionError>
pub fn new_congested_with_suggested_gas_price( suggested_gas_price: u64, ) -> Result<Self, VersionError>
Returns a special version used for congested shared objects:
Version::MIN_CONGESTED + suggested_gas_price,
where suggested_gas_price is embedded into a congested version
to facilitate a gas price feedback mechanism for transactions
canceled due to shared object congestion.
Sourcepub fn is_congested(&self) -> bool
pub fn is_congested(&self) -> bool
Check if this version is congested, i.e., the corresponding object is the reason for transaction cancellation.
Sourcepub fn get_congested_version_suggested_gas_price(
&self,
) -> Result<u64, VersionError>
pub fn get_congested_version_suggested_gas_price( &self, ) -> Result<u64, VersionError>
Returns the suggested_gas_price embedded in this congested shared
object version. The suggested_gas_price here is used for a
gas price feedback mechanism for transactions canceled due to
shared object congestion.
Sourcepub fn lamport_increment(
inputs: impl IntoIterator<Item = Self>,
) -> Result<Self, VersionError>
pub fn lamport_increment( inputs: impl IntoIterator<Item = Self>, ) -> Result<Self, VersionError>
Returns a new version that is greater than all versions
in inputs, assuming this operation will not overflow.
Sourcepub fn is_canceled(&self) -> bool
pub fn is_canceled(&self) -> bool
Checks if this version is canceled, i.e., the corresponding object appears in a canceled transaction.
Trait Implementations§
Source§impl AddAssign for Version
impl AddAssign for Version
Source§fn add_assign(&mut self, __rhs: Self)
fn add_assign(&mut self, __rhs: Self)
+= operation. Read moreSource§impl AddAssign<u64> for Version
impl AddAssign<u64> for Version
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+= operation. Read moreSource§impl Arbitrary for Version
Available on crate feature proptest only.
impl Arbitrary for Version
proptest only.Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = BoxedStrategy<Version>
type Strategy = BoxedStrategy<Version>
Strategy used to generate values of type Self.Source§fn arbitrary_with(
args_shared: <Self as Arbitrary>::Parameters,
) -> Self::Strategy
fn arbitrary_with( args_shared: <Self as Arbitrary>::Parameters, ) -> Self::Strategy
impl Copy for Version
Source§impl<'de> Deserialize<'de> for Version
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Version
serde only.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>,
Source§impl<__derive_more_Rhs> DivAssign<__derive_more_Rhs> for Version
impl<__derive_more_Rhs> DivAssign<__derive_more_Rhs> for Version
Source§fn div_assign(&mut self, __rhs: __derive_more_Rhs)
fn div_assign(&mut self, __rhs: __derive_more_Rhs)
/= operation. Read moreimpl Eq for Version
Source§impl<__derive_more_Rhs> MulAssign<__derive_more_Rhs> for Version
impl<__derive_more_Rhs> MulAssign<__derive_more_Rhs> for Version
Source§fn mul_assign(&mut self, __rhs: __derive_more_Rhs)
fn mul_assign(&mut self, __rhs: __derive_more_Rhs)
*= operation. Read moreSource§impl Ord for Version
impl Ord for Version
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Version
impl PartialOrd for Version
Source§impl PartialOrd<Version> for u64
impl PartialOrd<Version> for u64
Source§impl PartialOrd<u64> for Version
impl PartialOrd<u64> for Version
Source§impl<__derive_more_Rhs> RemAssign<__derive_more_Rhs> for Version
impl<__derive_more_Rhs> RemAssign<__derive_more_Rhs> for Version
Source§fn rem_assign(&mut self, __rhs: __derive_more_Rhs)
fn rem_assign(&mut self, __rhs: __derive_more_Rhs)
%= operation. Read moreimpl StructuralPartialEq for Version
Source§impl SubAssign for Version
impl SubAssign for Version
Source§fn sub_assign(&mut self, __rhs: Self)
fn sub_assign(&mut self, __rhs: Self)
-= operation. Read moreSource§impl SubAssign<u64> for Version
impl SubAssign<u64> for Version
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
-= operation. Read more