Skip to content

Commit

Permalink
chg: [poppy] make PoppyHash trait visible outside crate
Browse files Browse the repository at this point in the history
Signed-off-by: qjerome <qjerome@rawsec.lu>
  • Loading branch information
qjerome committed Apr 30, 2024
1 parent 260f4dc commit 418af73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions poppy/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ pub trait PoppyHasher: Hasher + Default {
}
}

/// Trait to implement for custom types to be inserted into filters
///
/// # Example
///
/// ```
/// use poppy_filters::PoppyHash;
///
/// #[derive(Hash)]
/// struct MyStruct {
/// some_int: i64,
/// s: String,
/// }
///
/// // PoppyHash can simply be implemented like this
/// // for any structure also implementing Hash trait
/// impl PoppyHash for MyStruct {};
///
/// ```
pub trait PoppyHash: Hash {
fn hash_pop<H: PoppyHasher>(&self) -> u64 {
let mut hasher = H::default();
Expand Down
1 change: 1 addition & 0 deletions poppy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ mod bloom;
pub use bloom::*;
pub mod bitset;
pub(crate) mod hash;
pub use hash::PoppyHash;
pub mod utils;

0 comments on commit 418af73

Please sign in to comment.