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§
Sourcefn next() -> Option<AssetId>
fn next() -> Option<AssetId>
The only id create may use, or None to accept any id not currently in use.
Sourcefn advance() -> Result<(), ()>
fn advance() -> Result<(), ()>
Allocate the id returned by Self::next, after a successful create.
Returns Err if the id space is exhausted.
Sourcefn advance_from(id: &AssetId) -> Result<(), ()>
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.
impl<AssetId> AssetIdAllocator<AssetId> for ()
No allocation policy: create accepts any unused id and NextAssetId has no effect.