git.delta.rocks / unique-network / refs/commits / 0f7bb4adb180

difftreelog

source

pallets/proxy-rmrk-core/src/misc.rs1.1 KiBsourcehistory
1use super::*;2use codec::{Encode, Decode};34#[macro_export]5macro_rules! map_common_err_to_proxy {6    (match $err:ident { $($common_err:ident => $proxy_err:ident),+ }) => {7        $(8            if $err == <CommonError<T>>::$common_err.into() {9                return <Error<T>>::$proxy_err.into()10            } else11        )+ {12            $err13        }14    };15}1617pub trait RmrkDecode<T: Decode + Default, S> {18	fn decode_or_default(&self) -> T;19}2021impl<T: Decode + Default, S> RmrkDecode<T, S> for BoundedVec<u8, S> {22	fn decode_or_default(&self) -> T {23		let mut value = self.as_slice();2425		T::decode(&mut value).unwrap_or_default()26	}27}2829pub trait RmrkRebind<T, S> {30	fn rebind(&self) -> BoundedVec<u8, S>;31}3233impl<T, S> RmrkRebind<T, S> for BoundedVec<u8, T>34where35	BoundedVec<u8, S>: TryFrom<Vec<u8>>,36{37	fn rebind(&self) -> BoundedVec<u8, S> {38		BoundedVec::<u8, S>::try_from(self.clone().into_inner()).unwrap_or_default()39	}40}4142#[derive(Encode, Decode, PartialEq, Eq)]43pub enum CollectionType {44	Regular,45	Resource,46	Base,47}4849#[derive(Encode, Decode, PartialEq, Eq)]50pub enum NftType {51	Regular,52	Resource,53	FixedPart,54	SlotPart,55	Theme,56}