Skip to main content

IndexOps

Trait IndexOps 

Source
pub trait IndexOps<Proprietor, Pallet>
where Pallet: LazyBalance<Asset = <Pallet as InspectAsset<Proprietor>>::Asset, Variant = Pallet::Position, Id = Pallet::Digest> + IndexVariant<Proprietor>,
{ // Required methods fn remove_index_entry( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, entry_of: &Pallet::Digest, ) -> Result<Pallet::Digest, DispatchError>; fn set_index_entry( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, entry_of: &Pallet::Digest, shares: Pallet::Shares, variant: &Pallet::Position, ) -> Result<Pallet::Digest, DispatchError>; }
Expand description

Defines operational behavior for managing indexed digests within a commitment system.

An IndexOps implementation extends IndexVariant to provide concrete management logic for a proprietor’s indexed commitments, where an index acts as a container of discrete digest entries.

Unlike pools (which aggregate balances collectively), indexes represent structured groupings of digests that can be individually set or removed, allowing for fine-grained commit management.

This trait defines low-level, unchecked operations - callers are responsible for ensuring validity and equilibrium before invoking these functions.

§Generics

  • Proprietor - the entity (e.g. account, vault, or manager) controlling the asset.
  • Pallet - the public struct implementing Commitment traits and LazyBalance, ensuring consistent asset accounting across the commitment system.

Required Methods§

Source

fn remove_index_entry( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, entry_of: &Pallet::Digest, ) -> Result<Pallet::Digest, DispatchError>

Removes a digest entry from an index for the given proprietor and reason.

Since indexes are immutable, this operation creates a new index without the specified entry and generates a new digest for it. The caller is responsible for managing the lifecycle of the old index digest.

This is a low-level, unchecked operation - callers must ensure equilibrium and invariant safety before calling.

§Returns
  • Ok(Digest) containing the new index digest after entry removal
  • Err(DispatchError) if the operation fails
Source

fn set_index_entry( who: &Proprietor, reason: &Pallet::Reason, index_of: &Pallet::Digest, entry_of: &Pallet::Digest, shares: Pallet::Shares, variant: &Pallet::Position, ) -> Result<Pallet::Digest, DispatchError>

Sets or updates a digest entry within an index and returns the new index digest.

Since indexes are immutable, this operation creates a new index with the updated entry configuration (shares and variant) and generates a new digest for it. If the entry exists, it is updated; otherwise, it is added.

This is a low-level, unchecked operation - callers must ensure equilibrium and invariant safety before calling.

§Returns
  • Ok(Digest) containing the new index digest after entry modification
  • Err(DispatchError) if the operation fails

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§