fedimint_walletv2_client/
db.rs1use fedimint_core::encoding::{Decodable, Encodable};
2use fedimint_core::{impl_db_lookup, impl_db_record};
3use serde::Serialize;
4use strum_macros::EnumIter;
5
6#[repr(u8)]
7#[derive(Clone, Debug, EnumIter)]
8pub enum DbKeyPrefix {
9 NextDepositIndex = 0x31,
10 ValidAddressIndex = 0x32,
11}
12
13impl std::fmt::Display for DbKeyPrefix {
14 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
15 write!(f, "{self:?}")
16 }
17}
18
19#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
20pub struct NextDepositIndexKey;
21
22impl_db_record!(
23 key = NextDepositIndexKey,
24 value = u64,
25 db_prefix = DbKeyPrefix::NextDepositIndex
26);
27
28#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
29pub struct ValidAddressIndexKey(pub u64);
30
31impl_db_record!(
32 key = ValidAddressIndexKey,
33 value = (),
34 db_prefix = DbKeyPrefix::ValidAddressIndex
35);
36
37#[derive(Clone, Debug, Encodable, Decodable, Serialize)]
38pub struct ValidAddressIndexPrefix;
39
40impl_db_lookup!(
41 key = ValidAddressIndexKey,
42 query_prefix = ValidAddressIndexPrefix
43);