Skip to content

Commit 5616542

Browse files
committed
nostr: impl Hash for TagIndexes
1 parent f4c5583 commit 5616542

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/nostr-database/src/tag_indexes.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ use nostr::{Alphabet, GenericTagValue};
1515
pub const TAG_INDEX_VALUE_SIZE: usize = 8;
1616

1717
/// Tag Indexes
18-
#[derive(Debug, Clone, Default, PartialEq, Eq)]
18+
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
1919
pub struct TagIndexes {
2020
inner: HashMap<Alphabet, TagIndexValues>,
2121
}
2222

23+
impl TagIndexes {
24+
#[allow(missing_docs)]
25+
pub fn new(map: BTreeMap<Alphabet, TagIndexValues>) -> Self {
26+
Self { inner: map }
27+
}
28+
}
29+
2330
impl Deref for TagIndexes {
2431
type Target = HashMap<Alphabet, TagIndexValues>;
2532
fn deref(&self) -> &Self::Target {
@@ -70,7 +77,7 @@ where
7077
}
7178

7279
/// Tag Index Values
73-
#[derive(Debug, Clone, Default, PartialEq, Eq)]
80+
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
7481
pub struct TagIndexValues {
7582
inner: HashSet<[u8; TAG_INDEX_VALUE_SIZE]>,
7683
}

0 commit comments

Comments
 (0)