referrerpolicy=no-referrer-when-downgrade

AssetIdAllocator

Trait AssetIdAllocator 

Source
pub trait AssetIdAllocator<AssetId> {
    // Required methods
    fn next() -> Option<AssetId>;
    fn advance() -> Result<(), ()>;
    fn advance_from(id: &AssetId) -> Result<(), ()>;
}
Expand description

Allocates the asset ids used by create.

Configure Config::AssetIdAllocator with () to leave create unconstrained, or with an impl such as AutoIncAssetId to enforce an allocation policy.

Required Methods§

Source

fn next() -> Option<AssetId>

The only id create may use, or None to accept any id not currently in use.

Source

fn advance() -> Result<(), ()>

Allocate the id returned by Self::next, after a successful create.

Returns Err if the id space is exhausted.

Source

fn advance_from(id: &AssetId) -> Result<(), ()>

Allocate id, after a successful force_create, so Self::next can never return it.

Returns Err if the id space is exhausted.

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<AssetId> AssetIdAllocator<AssetId> for ()

No allocation policy: create accepts any unused id and NextAssetId has no effect.

Implementors§

Source§

impl<T: Config<I>, I: 'static> AssetIdAllocator<<T as Config<I>>::AssetId> for AutoIncAssetId<T, I>
where T::AssetId: Incrementable + PartialOrd,