VersioningFactory

Trait VersioningFactory 

Source
pub trait VersioningFactory {
    type Output;
    type Error;
    type Arguments;

    // Required methods
    fn get_component() -> MipComponent;
    fn get_versioning_store(&self) -> MipStore;
    fn create(
        &self,
        args: &Self::Arguments,
        strategy: FactoryStrategy,
    ) -> Result<Self::Output, Self::Error>;

    // Provided methods
    fn get_latest_component_version_at(
        &self,
        ts: MassaTime,
    ) -> Result<u32, FactoryError> { ... }
    fn get_all_active_component_versions(&self) -> Vec<u32> { ... }
    fn get_all_component_versions(&self) -> BTreeMap<u32, ComponentStateTypeId> { ... }
    fn get_component_version_with_strategy(
        &self,
        strategy: FactoryStrategy,
    ) -> Result<u32, FactoryError> { ... }
}
Expand description

Trait for Factory that create objects based on versioning store

Required Associated Types§

Source

type Output

Factory will create only one object of a given type, so a FactoryAddress (impl VersioningFactory), will have type Output = Address

Source

type Error

Error if object cannot be created (+ used for VersioningFactoryArgs)

Source

type Arguments

Arguments struct in order to create Self::Output

Required Methods§

Source

fn get_component() -> MipComponent

Return the MipComponent associated with return type (Output) e.g. if type Output = Address, should return MipComponent::Address

Source

fn get_versioning_store(&self) -> MipStore

Access to the MipStore

Source

fn create( &self, args: &Self::Arguments, strategy: FactoryStrategy, ) -> Result<Self::Output, Self::Error>

Create an object of type Self::Output

Provided Methods§

Source

fn get_latest_component_version_at( &self, ts: MassaTime, ) -> Result<u32, FactoryError>

Get latest version at given timestamp (e.g. slot)

Source

fn get_all_active_component_versions(&self) -> Vec<u32>

Get all versions in ‘Active state’ for the associated MipComponent

Source

fn get_all_component_versions(&self) -> BTreeMap<u32, ComponentStateTypeId>

Get all versions (at any state) for the associated MipComponent

Source

fn get_component_version_with_strategy( &self, strategy: FactoryStrategy, ) -> Result<u32, FactoryError>

Get the version the current component with the given strategy

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.

Implementors§