commonware_storage/
lib.rs1#![doc(
8 html_logo_url = "https://commonware.xyz/imgs/rustdoc_logo.svg",
9 html_favicon_url = "https://commonware.xyz/favicon.ico"
10)]
11#![cfg_attr(not(any(feature = "std", test)), no_std)]
12
13commonware_macros::stability_scope!(ALPHA {
14 extern crate alloc;
15
16 pub mod bmt;
17 pub mod merkle;
18 pub use merkle::{mmb, mmr};
19});
20commonware_macros::stability_scope!(ALPHA, cfg(feature = "std") {
21 mod bitmap;
22 pub mod qmdb;
23 pub use crate::bitmap::{BitMap as AuthenticatedBitMap, MerkleizedBitMap, UnmerkleizedBitMap};
24 pub mod cache;
25 pub mod queue;
26 #[cfg(any(test, feature = "test-utils"))]
27 pub mod utils;
28});
29commonware_macros::stability_scope!(BETA, cfg(feature = "std") {
30 pub mod archive;
31 pub mod freezer;
32 pub mod index;
33 pub mod journal;
34 pub mod metadata;
35 pub mod ordinal;
36 pub mod rmap;
37
38 pub trait Sections {
40 type Iter: Iterator<Item = u64>;
42
43 fn sections(self) -> Self::Iter;
48 }
49
50 impl Sections for u64 {
51 type Iter = core::iter::Once<Self>;
52
53 fn sections(self) -> Self::Iter {
54 core::iter::once(self)
55 }
56 }
57
58 impl<const N: usize> Sections for [u64; N] {
59 type Iter = core::array::IntoIter<u64, N>;
60
61 fn sections(self) -> Self::Iter {
62 self.into_iter()
63 }
64 }
65
66 impl<'a, const N: usize> Sections for &'a [u64; N] {
67 type Iter = core::iter::Copied<core::slice::Iter<'a, u64>>;
68
69 fn sections(self) -> Self::Iter {
70 self.iter().copied()
71 }
72 }
73
74 impl<'a> Sections for &'a [u64] {
75 type Iter = core::iter::Copied<core::slice::Iter<'a, u64>>;
76
77 fn sections(self) -> Self::Iter {
78 self.iter().copied()
79 }
80 }
81
82 impl Sections for Vec<u64> {
83 type Iter = std::vec::IntoIter<u64>;
84
85 fn sections(self) -> Self::Iter {
86 self.into_iter()
87 }
88 }
89
90 impl<'a> Sections for &'a Vec<u64> {
91 type Iter = core::iter::Copied<core::slice::Iter<'a, u64>>;
92
93 fn sections(self) -> Self::Iter {
94 self.iter().copied()
95 }
96 }
97
98 impl Sections for std::collections::BTreeSet<u64> {
99 type Iter = std::collections::btree_set::IntoIter<u64>;
100
101 fn sections(self) -> Self::Iter {
102 self.into_iter()
103 }
104 }
105
106 impl<'a> Sections for &'a std::collections::BTreeSet<u64> {
107 type Iter = core::iter::Copied<std::collections::btree_set::Iter<'a, u64>>;
108
109 fn sections(self) -> Self::Iter {
110 self.iter().copied()
111 }
112 }
113
114 pub trait Context:
119 commonware_runtime::BufferPooler
120 + commonware_runtime::Storage
121 + commonware_runtime::Clock
122 + commonware_runtime::Metrics
123 {
124 }
125 impl<
126 T: commonware_runtime::BufferPooler
127 + commonware_runtime::Storage
128 + commonware_runtime::Clock
129 + commonware_runtime::Metrics,
130 > Context for T
131 {
132 }
133});
134commonware_macros::stability_scope!(BETA {
135 pub mod translator;
136});