We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is an example implementation for an enum. This would lend itself very well to a derive macro.
/// Unique addresses #[derive(Copy, Display, FromPrimitive)] #[cw_serde] pub enum ConfigUnique { PriceOracle, Market, InterestModel, WarChest, Governance, AdminDoubleSig, AdminTripleSig, Owner, } impl<'a> PrimaryKey<'a> for ConfigUnique { type Prefix = (); type SubPrefix = (); type Suffix = Self; type SuperSuffix = Self; fn key(&self) -> Vec<Key> { vec![Key::Val8([*self as u8])] } } impl KeyDeserialize for ConfigUnique { type Output = ConfigUnique; #[inline(always)] fn from_vec(value: Vec<u8>) -> StdResult<Self::Output> { FromPrimitive::from_u8(value[0]).ok_or_else(|| StdError::generic_err("Invalid ConfigUnique")) } }
The text was updated successfully, but these errors were encountered:
Another slightly less clean way to accomplish this is
impl<'a, T> PrimaryKey<'a> for T where T: FromPrimitive { ... }
Sorry, something went wrong.
No branches or pull requests
Here is an example implementation for an enum. This would lend itself very well to a derive macro.
The text was updated successfully, but these errors were encountered: