1234567891011121314151617use super::*;18use core::convert::AsRef;1920pub enum RmrkProperty<'r> {21 Metadata,22 CollectionType,23 RmrkInternalCollectionId,24 TokenType,25 Transferable,26 RoyaltyInfo,27 Equipped,28 ResourceCollection,29 ResourcePriorities,30 ResourceType,31 PendingNftAccept,32 PendingResourceAccept,33 PendingResourceRemoval,34 Parts,35 Base,36 Src,37 Slot,38 License,39 Thumb,40 EquippedNft,41 BaseType,42 ExternalPartId,43 EquippableList,44 ZIndex,45 ThemeName,46 ThemeInherit,47 UserProperty(&'r [u8]),48}4950impl<'r> RmrkProperty<'r> {51 pub fn to_key<T: Config>(self) -> Result<PropertyKey, Error<T>> {52 fn get_bytes<T: AsRef<[u8]>>(container: &T) -> &[u8] {53 container.as_ref()54 }5556 macro_rules! key {57 ($($component:expr),+) => {58 PropertyKey::try_from([$(key!(@ &$component)),+].concat())59 .map_err(|_| <Error<T>>::RmrkPropertyKeyIsTooLong)60 };6162 (@ $key:expr) => {63 get_bytes($key)64 };65 }6667 match self {68 Self::Metadata => key!("metadata"),69 Self::CollectionType => key!("collection-type"),70 Self::RmrkInternalCollectionId => key!("internal-id"),71 Self::TokenType => key!("token-type"),72 Self::Transferable => key!("transferable"),73 Self::RoyaltyInfo => key!("royalty-info"),74 Self::Equipped => key!("equipped"),75 Self::ResourceCollection => key!("resource-collection"),76 Self::ResourcePriorities => key!("resource-priorities"),77 Self::ResourceType => key!("resource-type"),78 Self::PendingNftAccept => key!("pending-nft-accept"),79 Self::PendingResourceAccept => key!("pending-resource-accept"),80 Self::PendingResourceRemoval => key!("pending-resource-removal"),81 Self::Parts => key!("parts"),82 Self::Base => key!("base"),83 Self::Src => key!("src"),84 Self::Slot => key!("slot"),85 Self::License => key!("license"),86 Self::Thumb => key!("thumb"),87 Self::EquippedNft => key!("equipped-nft"),88 Self::BaseType => key!("base-type"),89 Self::ExternalPartId => key!("ext-part-id"),90 Self::EquippableList => key!("equippable-list"),91 Self::ZIndex => key!("z-index"),92 Self::ThemeName => key!("theme-name"),93 Self::ThemeInherit => key!("theme-inherit"),94 Self::UserProperty(name) => key!("userprop-", name),95 }96 }97}