Trait ConsignmentApi

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

    // Required methods
    fn schema(&self) -> &Schema<Schema<()>>;
    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 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>>

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§

Source§

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

Source§

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