git.delta.rocks / unique-network / refs/commits / 7e808da4a3d9

difftreelog

source

pallets/proxy-rmrk-core/src/property.rs1.9 KiBsourcehistory
1use super::*;2use core::convert::AsRef;34pub enum RmrkProperty<'r> {5	Metadata,6	CollectionType,7	TokenType,8	RoyaltyInfo,9	Equipped,10	ResourceCollection,11	ResourcePriorities,12	ResourceType,13	PendingResourceAccept,14	PendingResourceRemoval,15	Parts,16	Base,17	Src,18	Slot,19	License,20	Thumb,21	EquippedNft,22	BaseType,23	ExternalPartId,24	EquippableList,25	ZIndex,26	ThemeName,27	ThemeInherit,28	UserProperty(&'r [u8]),29}3031impl<'r> RmrkProperty<'r> {32	pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {33		fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {34			container.as_ref()35		}3637		macro_rules! key {38            ($($component:expr),+) => {39                PropertyKey::try_from([$(key!(@ &$component)),+].concat())40                    .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)41            };4243            (@ $key:expr) => {44                get_bytes($key)45            };46        }4748		match self {49			Self::Metadata => key!("metadata"),50			Self::CollectionType => key!("collection-type"),51			Self::TokenType => key!("token-type"),52			Self::RoyaltyInfo => key!("royalty-info"),53			Self::Equipped => key!("equipped"),54			Self::ResourceCollection => key!("resource-collection"),55			Self::ResourcePriorities => key!("resource-priorities"),56			Self::ResourceType => key!("resource-type"),57			Self::PendingResourceAccept => key!("pending-accept"),58			Self::PendingResourceRemoval => key!("pending-removal"),59			Self::Parts => key!("parts"),60			Self::Base => key!("base"),61			Self::Src => key!("src"),62			Self::Slot => key!("slot"),63			Self::License => key!("license"),64			Self::Thumb => key!("thumb"),65			Self::EquippedNft => key!("equipped-nft"),66			Self::BaseType => key!("base-type"),67			Self::ExternalPartId => key!("ext-part-id"),68			Self::EquippableList => key!("equippable-list"),69			Self::ZIndex => key!("z-index"),70			Self::ThemeName => key!("theme-name"),71			Self::ThemeInherit => key!("theme-inherit"),72			Self::UserProperty(name) => key!("userprop-", name),73		}74	}75}