mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
use associated iterator types for InspectEnumerable (#12389)
* use associated iterator types for InspectEnumerable * Update frame/uniques/src/impl_nonfungibles.rs Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -65,11 +65,16 @@ pub trait Inspect<AccountId> {
|
||||
/// Interface for enumerating items in existence or owned by a given account over a collection
|
||||
/// of NFTs.
|
||||
pub trait InspectEnumerable<AccountId>: Inspect<AccountId> {
|
||||
/// The iterator type for [`Self::items`].
|
||||
type ItemsIterator: Iterator<Item = Self::ItemId>;
|
||||
/// The iterator type for [`Self::owned`].
|
||||
type OwnedIterator: Iterator<Item = Self::ItemId>;
|
||||
|
||||
/// Returns an iterator of the items within a `collection` in existence.
|
||||
fn items() -> Box<dyn Iterator<Item = Self::ItemId>>;
|
||||
fn items() -> Self::ItemsIterator;
|
||||
|
||||
/// Returns an iterator of the items of all collections owned by `who`.
|
||||
fn owned(who: &AccountId) -> Box<dyn Iterator<Item = Self::ItemId>>;
|
||||
fn owned(who: &AccountId) -> Self::OwnedIterator;
|
||||
}
|
||||
|
||||
/// Trait for providing an interface for NFT-like items which may be minted, burned and/or have
|
||||
@@ -149,10 +154,15 @@ impl<
|
||||
AccountId,
|
||||
> InspectEnumerable<AccountId> for ItemOf<F, A, AccountId>
|
||||
{
|
||||
fn items() -> Box<dyn Iterator<Item = Self::ItemId>> {
|
||||
type ItemsIterator = <F as nonfungibles::InspectEnumerable<AccountId>>::ItemsIterator;
|
||||
type OwnedIterator =
|
||||
<F as nonfungibles::InspectEnumerable<AccountId>>::OwnedInCollectionIterator;
|
||||
|
||||
fn items() -> Self::ItemsIterator {
|
||||
<F as nonfungibles::InspectEnumerable<AccountId>>::items(&A::get())
|
||||
}
|
||||
fn owned(who: &AccountId) -> Box<dyn Iterator<Item = Self::ItemId>> {
|
||||
|
||||
fn owned(who: &AccountId) -> Self::OwnedIterator {
|
||||
<F as nonfungibles::InspectEnumerable<AccountId>>::owned_in_collection(&A::get(), who)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,20 +105,29 @@ pub trait Inspect<AccountId> {
|
||||
/// Interface for enumerating items in existence or owned by a given account over many collections
|
||||
/// of NFTs.
|
||||
pub trait InspectEnumerable<AccountId>: Inspect<AccountId> {
|
||||
/// The iterator type for [`Self::collections`].
|
||||
type CollectionsIterator: Iterator<Item = Self::CollectionId>;
|
||||
/// The iterator type for [`Self::items`].
|
||||
type ItemsIterator: Iterator<Item = Self::ItemId>;
|
||||
/// The iterator type for [`Self::owned`].
|
||||
type OwnedIterator: Iterator<Item = (Self::CollectionId, Self::ItemId)>;
|
||||
/// The iterator type for [`Self::owned_in_collection`].
|
||||
type OwnedInCollectionIterator: Iterator<Item = Self::ItemId>;
|
||||
|
||||
/// Returns an iterator of the collections in existence.
|
||||
fn collections() -> Box<dyn Iterator<Item = Self::CollectionId>>;
|
||||
fn collections() -> Self::CollectionsIterator;
|
||||
|
||||
/// Returns an iterator of the items of a `collection` in existence.
|
||||
fn items(collection: &Self::CollectionId) -> Box<dyn Iterator<Item = Self::ItemId>>;
|
||||
fn items(collection: &Self::CollectionId) -> Self::ItemsIterator;
|
||||
|
||||
/// Returns an iterator of the items of all collections owned by `who`.
|
||||
fn owned(who: &AccountId) -> Box<dyn Iterator<Item = (Self::CollectionId, Self::ItemId)>>;
|
||||
fn owned(who: &AccountId) -> Self::OwnedIterator;
|
||||
|
||||
/// Returns an iterator of the items of `collection` owned by `who`.
|
||||
fn owned_in_collection(
|
||||
collection: &Self::CollectionId,
|
||||
who: &AccountId,
|
||||
) -> Box<dyn Iterator<Item = Self::ItemId>>;
|
||||
) -> Self::OwnedInCollectionIterator;
|
||||
}
|
||||
|
||||
/// Trait for providing the ability to create collections of nonfungible items.
|
||||
|
||||
Reference in New Issue
Block a user