fedimint_empty_server/
db.rs

1use fedimint_core::encoding::{Decodable, Encodable};
2use fedimint_core::{impl_db_lookup, impl_db_record};
3use serde::Serialize;
4use strum_macros::EnumIter;
5
6/// Namespaces DB keys for this module
7#[repr(u8)]
8#[derive(Clone, EnumIter, Debug)]
9pub enum DbKeyPrefix {
10    Example = 0x01,
11}
12
13// TODO: Boilerplate-code
14impl std::fmt::Display for DbKeyPrefix {
15    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16        write!(f, "{self:?}")
17    }
18}
19
20#[derive(Debug, Clone, Encodable, Decodable, Eq, PartialEq, Hash, Serialize)]
21pub struct EmptyExampleKey(#[serde(with = "::fedimint_core::encoding::as_hex")] pub Vec<u8>);
22
23#[derive(Debug, Encodable, Decodable)]
24pub struct EmptyExampleKeyPrefix;
25
26impl_db_record!(
27    key = EmptyExampleKey,
28    value = Vec<u8>,
29    db_prefix = DbKeyPrefix::Example,
30);
31impl_db_lookup!(key = EmptyExampleKey, query_prefix = EmptyExampleKeyPrefix,);