pub trait ConsignmentApi {
    type BundleIter<'container>: Iterator<Item = &'container AnchoredBundle>
       where Self: 'container;

    // Required methods
    fn schema(&self) -> &Schema<Schema<()>>;
    fn asset_tags(&self) -> &BTreeMap<AssignmentType, AssetTag>;
    fn operation(&self, opid: OpId) -> Option<OpRef<'_>>;
    fn genesis(&self) -> &Genesis;
    fn transition(&self, opid: OpId) -> Option<&Transition>;
    fn extension(&self, opid: OpId) -> Option<&Extension>;
    fn terminals(&self) -> BTreeSet<(BundleId, SecretSeal)>;
    fn anchored_bundles(&self) -> Self::BundleIter<'_>;
    fn bundle_by_id(&self, bundle_id: BundleId) -> Option<&TransitionBundle>;
    fn op_ids_except(&self, ids: &BTreeSet<OpId>) -> BTreeSet<OpId>;
    fn has_operation(&self, opid: OpId) -> bool;
    fn known_transitions_by_bundle_id(
        &self,
        bundle_id: BundleId
    ) -> Option<Vec<&Transition>>;
}
Expand description

Trait defining common data access API for all storage-related RGB structures

Verification

The function does not verify the internal consistency, schema conformance or validation status of the RGB contract data withing the storage or container; these checks must be performed as a separate step before calling any of the [ContainerApi] methods. If the methods are called on non-validated/unchecked data this may result in returned [Error] or None values from the API methods.

Required Associated Types§

source

type BundleIter<'container>: Iterator<Item = &'container AnchoredBundle> where Self: 'container

Required Methods§

source

fn schema(&self) -> &Schema<Schema<()>>

source

fn asset_tags(&self) -> &BTreeMap<AssignmentType, AssetTag>

Asset tags uses in the confidential asset validation.

source

fn operation(&self, opid: OpId) -> Option<OpRef<'_>>

Retrieves reference to a operation (genesis, state transition or state extension) matching the provided id, or None otherwise

source

fn genesis(&self) -> &Genesis

Contract genesis.

source

fn transition(&self, opid: OpId) -> Option<&Transition>

Returns reference to a state transition, if known, matching the provided id. If id is unknown, or corresponds to other type of the operation (genesis or state extensions) a error is returned.

Errors
  • [Error::WrongNodeType] when operation is present, but has some other operation type
  • [Error::TransitionAbsent] when operation with the given id is absent from the storage/container
source

fn extension(&self, opid: OpId) -> Option<&Extension>

Returns reference to a state extension, if known, matching the provided id. If id is unknown, or corresponds to other type of the operation (genesis or state transition) a error is returned.

Errors
  • [Error::WrongNodeType] when operation is present, but has some other operation type
  • [Error::ExtensionAbsent] when operation with the given id is absent from the storage/container
source

fn terminals(&self) -> BTreeSet<(BundleId, SecretSeal)>

The final state (“endpoints”) provided by this consignment.

There are two reasons for having endpoints:

  • navigation towards genesis from the final state is more computationally efficient, since state transition/extension graph is directed towards genesis (like bitcoin transaction graph)
  • if the consignment contains concealed state (known by the receiver), it will be computationally inefficient to understand which of the state transitions represent the final state
source

fn anchored_bundles(&self) -> Self::BundleIter<'_>

Data on all anchored state transitions contained in the consignment

source

fn bundle_by_id(&self, bundle_id: BundleId) -> Option<&TransitionBundle>

source

fn op_ids_except(&self, ids: &BTreeSet<OpId>) -> BTreeSet<OpId>

source

fn has_operation(&self, opid: OpId) -> bool

source

fn known_transitions_by_bundle_id( &self, bundle_id: BundleId ) -> Option<Vec<&Transition>>

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<const TYPE: bool> ConsignmentApi for Consignment<TYPE>

§

type BundleIter<'container> = Iter<'container, AnchoredBundle> where Self: 'container