Versioned

Trait Versioned 

Source
pub trait Versioned:
    AsRef<Self::Versions>
    + AsMut<Self::Versions>
    + From<Self::Versions> {
    type Versions: From<Self>;
    type LatestVersion;

    // Required methods
    fn is_fully_updated(&self) -> bool;
    fn in_place_fully_update(&mut self) -> &mut Self;
    fn fully_update_and_into_latest_version(self) -> Self::LatestVersion;
    fn from_latest_version(latest: Self::LatestVersion) -> Self;
    fn as_latest_version(&self) -> Option<&Self::LatestVersion>;
    fn as_latest_version_mut(&mut self) -> Option<&mut Self::LatestVersion>;
    fn as_versions(&self) -> &Self::Versions;
    fn as_versions_mut(&mut self) -> &mut Self::Versions;
    fn into_versions(self) -> Self::Versions;
    fn from_versions(version: Self::Versions) -> Self;

    // Provided methods
    fn in_place_fully_update_and_as_latest_version_mut(
        &mut self,
    ) -> &mut Self::LatestVersion { ... }
    fn fully_update(self) -> Self { ... }
}
Expand description

A trait implemented by versioned types created via define_versioned and define_single_versioned.

A versioned type is a type wrapping an enum, this enum is the associated type Versioned::Versions, and contains a variant for each supported version.

This Versioned type itself is a struct wrapper around this enum, which allows for fully updating the contained version to Versioned::LatestVersion. This wrapper is required so that the wrapper can take ownership of old versions as part of the upgrade process, in order to incrementally update them using the From trait.

Required Associated Types§

Source

type Versions: From<Self>

The type for the enum of versions.

Source

type LatestVersion

The type for the latest content.

Required Methods§

Source

fn is_fully_updated(&self) -> bool

Returns true if at the latest version.

Source

fn in_place_fully_update(&mut self) -> &mut Self

Updates to the latest version in place.

Source

fn fully_update_and_into_latest_version(self) -> Self::LatestVersion

Updates itself to the latest version, then returns the latest content

Source

fn from_latest_version(latest: Self::LatestVersion) -> Self

Constructs a versioned wrapper around the latest content

Source

fn as_latest_version(&self) -> Option<&Self::LatestVersion>

If the versioned wrapper is at the latest version, it returns an immutable reference to the latest content, otherwise it returns None.

If you require the latest version unconditionally, consider using [in_place_fully_update_and_as_latest_version_mut] to update to the latest version first - or, if there is only a single version, use [as_unique_version].

Source

fn as_latest_version_mut(&mut self) -> Option<&mut Self::LatestVersion>

If the versioned wrapper is at the latest version, it returns a mutable reference to the latest content, otherwise it returns None.

If you require the latest version unconditionally, consider using [in_place_fully_update_and_as_latest_version_mut] to update to the latest version first - or, if there is only a single version, use [as_unique_version_mut].

Source

fn as_versions(&self) -> &Self::Versions

Gets a reference the inner versions enum, for e.g. matching on the enum.

This is essentially a clearer alias for as_ref.

Source

fn as_versions_mut(&mut self) -> &mut Self::Versions

Gets a mutable reference the inner versions enum, for e.g. matching on the enum.

This is essentially a clearer alias for as_mut.

Source

fn into_versions(self) -> Self::Versions

Removes the upgradable wrapper to get at the inner versions enum, for e.g. matching on the enum.

Source

fn from_versions(version: Self::Versions) -> Self

Creates a new Versioned wrapper from a given specific version.

Provided Methods§

Source

fn in_place_fully_update_and_as_latest_version_mut( &mut self, ) -> &mut Self::LatestVersion

Updates the latest version in place, and returns a &mut to the latest content

Source

fn fully_update(self) -> Self

Consumes self, updates to the latest version and returns itself.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Versioned for VersionedAccountAuthorizedDepositor

Source§

impl Versioned for VersionedAccountDepositRule

Source§

impl Versioned for VersionedAccountResourcePreference

Source§

impl Versioned for VersionedAccountResourceVault

Source§

impl Versioned for VersionedAccountLockerAccountClaims

Source§

impl Versioned for VersionedMetadataEntry

Source§

impl Versioned for VersionedRoleAssignmentAccessRule

Source§

impl Versioned for VersionedRoleAssignmentOwner

Source§

impl Versioned for VersionedComponentRoyaltyAccumulator

Source§

impl Versioned for VersionedComponentRoyaltyMethodAmount

Source§

impl Versioned for VersionedTreeNode

Source§

impl Versioned for TransactionValidationConfigurationSubstate

Implementors§

Source§

impl Versioned for VersionedMultiResourcePoolState

Source§

impl Versioned for VersionedOneResourcePoolState

Source§

impl Versioned for VersionedTwoResourcePoolState

Source§

impl Versioned for ProtocolUpdateStatusSummarySubstate

Source§

impl Versioned for VersionedConsensusManagerConfiguration

Source§

impl Versioned for VersionedConsensusManagerCurrentProposalStatistic

Source§

impl Versioned for VersionedConsensusManagerCurrentValidatorSet

Source§

impl Versioned for VersionedConsensusManagerProposerMilliTimestamp

Source§

impl Versioned for VersionedConsensusManagerProposerMinuteTimestamp

Source§

impl Versioned for VersionedConsensusManagerRegisteredValidatorByStake

Source§

impl Versioned for VersionedConsensusManagerState

Source§

impl Versioned for VersionedConsensusManagerValidatorRewards

Source§

impl Versioned for VersionedFungibleResourceManagerDivisibility

Source§

impl Versioned for VersionedFungibleResourceManagerTotalSupply

Source§

impl Versioned for VersionedFungibleVaultBalance

Source§

impl Versioned for VersionedFungibleVaultFreezeStatus

Source§

impl Versioned for VersionedFungibleVaultLockedBalance

Source§

impl Versioned for VersionedLedgerTransactionHashes

Source§

impl Versioned for VersionedNonFungibleResourceManagerIdType

Source§

impl Versioned for VersionedNonFungibleResourceManagerMutableFields

Source§

impl Versioned for VersionedNonFungibleResourceManagerTotalSupply

Source§

impl Versioned for VersionedNonFungibleVaultBalance

Source§

impl Versioned for VersionedNonFungibleVaultFreezeStatus

Source§

impl Versioned for VersionedNonFungibleVaultLockedResource

Source§

impl Versioned for VersionedNonFungibleVaultNonFungible

Source§

impl Versioned for VersionedPackageBlueprintVersionAuthConfig

Source§

impl Versioned for VersionedPackageBlueprintVersionDefinition

Source§

impl Versioned for VersionedPackageBlueprintVersionDependencies

Source§

impl Versioned for VersionedPackageBlueprintVersionRoyaltyConfig

Source§

impl Versioned for VersionedPackageCodeInstrumentedCode

Source§

impl Versioned for VersionedPackageCodeOriginalCode

Source§

impl Versioned for VersionedPackageCodeVmType

Source§

impl Versioned for VersionedPackageRoyaltyAccumulator

Source§

impl Versioned for VersionedValidatorProtocolUpdateReadinessSignal

Source§

impl Versioned for VersionedValidatorState

Source§

impl Versioned for VersionedAccessControllerState

Source§

impl Versioned for VersionedAccessControllerV2State

Source§

impl<S> Versioned for VersionedSchema<S>
where S: CustomSchema,