Skip to main content

Version

Struct Version 

Source
pub struct Version(/* private fields */);

Implementations§

Source§

impl Version

Source

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.

Source

pub const INITIAL_SHARED_VERSION: Self

The initial shared version for shared system objects.

Source

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.

Source

pub const CANCELED_READ: Self

Special version that is assigned to objects which are accessed immutably in a canceled transaction.

Source

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.

Source

pub const RANDOMNESS_UNAVAILABLE: Self

Source

pub const OBJECT_START: Self

Source

pub const fn from_u64(value: u64) -> Self

Create a new Version from a u64 value

Source

pub const fn as_u64(&self) -> u64

Get the underlying u64 value of this version

Source

pub fn next(self) -> Result<Self, VersionError>

Returns the next version, or an error if overflow occurs.

Source

pub fn increment(&mut self) -> Result<(), VersionError>

Increments this version by one, or returns an error if overflow occurs.

Source

pub fn previous(self) -> Result<Self, VersionError>

Returns the previous version, or an error if underflow occurs.

Source

pub fn decrement(&mut self) -> Result<(), VersionError>

Decrements this version by one, or returns an error if underflow occurs.

Source

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.

Source

pub fn is_congested(&self) -> bool

Check if this version is congested, i.e., the corresponding object is the reason for transaction cancellation.

Source

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.

Source

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.

Source

pub fn is_canceled(&self) -> bool

Checks if this version is canceled, i.e., the corresponding object appears in a canceled transaction.

Source

pub fn is_valid(&self) -> bool

Checks if this version is valid, i.e., the corresponding object does not appear in a canceled transaction.

Trait Implementations§

Source§

impl Add for Version

Source§

type Output = Version

The resulting type after applying the + operator.
Source§

fn add(self, __rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<u64> for Version

Source§

type Output = Version

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for Version

Source§

fn add_assign(&mut self, __rhs: Self)

Performs the += operation. Read more
Source§

impl AddAssign<u64> for Version

Source§

fn add_assign(&mut self, rhs: u64)

Performs the += operation. Read more
Source§

impl Arbitrary for Version

Available on crate feature proptest only.
Source§

type Parameters = ()

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
Source§

type Strategy = BoxedStrategy<Version>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with( args_shared: <Self as Arbitrary>::Parameters, ) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl Clone for Version

Source§

fn clone(&self) -> Version

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Version

Source§

impl Debug for Version

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Version

Source§

fn default() -> Version

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Version

Available on crate feature serde only.
Source§

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 Version

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<__derive_more_Rhs> Div<__derive_more_Rhs> for Version
where u64: Div<__derive_more_Rhs, Output = u64>,

Source§

type Output = Version

The resulting type after applying the / operator.
Source§

fn div(self, __rhs: __derive_more_Rhs) -> Self::Output

Performs the / operation. Read more
Source§

impl<__derive_more_Rhs> DivAssign<__derive_more_Rhs> for Version
where u64: DivAssign<__derive_more_Rhs>,

Source§

fn div_assign(&mut self, __rhs: __derive_more_Rhs)

Performs the /= operation. Read more
Source§

impl Eq for Version

Source§

impl From<u64> for Version

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Version

Source§

type Err = <u64 as FromStr>::Err

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Version

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<__derive_more_Rhs> Mul<__derive_more_Rhs> for Version
where u64: Mul<__derive_more_Rhs, Output = u64>,

Source§

type Output = Version

The resulting type after applying the * operator.
Source§

fn mul(self, __rhs: __derive_more_Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl<__derive_more_Rhs> MulAssign<__derive_more_Rhs> for Version
where u64: MulAssign<__derive_more_Rhs>,

Source§

fn mul_assign(&mut self, __rhs: __derive_more_Rhs)

Performs the *= operation. Read more
Source§

impl Ord for Version

Source§

fn cmp(&self, other: &Version) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Version

Source§

fn eq(&self, other: &Version) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<Version> for u64

Source§

fn eq(&self, other: &Version) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<u64> for Version

Source§

fn eq(&self, other: &u64) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Version

Source§

fn partial_cmp(&self, other: &Version) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Version> for u64

Source§

fn partial_cmp(&self, other: &Version) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u64> for Version

Source§

fn partial_cmp(&self, other: &u64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<__derive_more_Rhs> Rem<__derive_more_Rhs> for Version
where u64: Rem<__derive_more_Rhs, Output = u64>,

Source§

type Output = Version

The resulting type after applying the % operator.
Source§

fn rem(self, __rhs: __derive_more_Rhs) -> Self::Output

Performs the % operation. Read more
Source§

impl<__derive_more_Rhs> RemAssign<__derive_more_Rhs> for Version
where u64: RemAssign<__derive_more_Rhs>,

Source§

fn rem_assign(&mut self, __rhs: __derive_more_Rhs)

Performs the %= operation. Read more
Source§

impl Serialize for Version

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Version

Source§

impl Sub for Version

Source§

type Output = Version

The resulting type after applying the - operator.
Source§

fn sub(self, __rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<u64> for Version

Source§

type Output = Version

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u64) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for Version

Source§

fn sub_assign(&mut self, __rhs: Self)

Performs the -= operation. Read more
Source§

impl SubAssign<u64> for Version

Source§

fn sub_assign(&mut self, rhs: u64)

Performs the -= operation. Read more
Source§

impl Sum for Version

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryFrom<i64> for Version

Source§

type Error = <u64 as TryFrom<i64>>::Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V