hashes: Move from_engine function to other macro
The `from_engine` function is associated with a general hash type but we are defining it in the `hash_type` macro which holds nothing but functions associated with the `Hash` trait. By "associated" I mean methods on the type as opposed to trait methods. In preparation for re-naming the `hash_type` macro move the `from_engine` function there. Requires duplicating the code in the `siphash` impl block, this is as expected because the `siphash` requires a custom implementation of the general hashing functionality. Internal change only.
This commit is contained in:
parent
bb7dd2c479
commit
62617cf9ac
|
@ -130,6 +130,9 @@ macro_rules! hash_type {
|
|||
$crate::internal_macros::hash_type_no_default!($bits, $reverse, $doc);
|
||||
|
||||
impl Hash {
|
||||
/// Produces a hash from the current state of a given engine.
|
||||
pub fn from_engine(e: HashEngine) -> Hash { from_engine(e) }
|
||||
|
||||
/// Constructs a new engine.
|
||||
pub fn engine() -> HashEngine { Default::default() }
|
||||
|
||||
|
@ -180,9 +183,6 @@ macro_rules! hash_type_no_default {
|
|||
unsafe { &mut *(bytes as *mut _ as *mut Self) }
|
||||
}
|
||||
|
||||
/// Produces a hash from the current state of a given engine.
|
||||
pub fn from_engine(e: HashEngine) -> Hash { from_engine(e) }
|
||||
|
||||
/// Copies a byte slice into a hash object.
|
||||
pub fn from_slice(
|
||||
sl: &[u8],
|
||||
|
|
|
@ -168,6 +168,9 @@ impl crate::HashEngine for HashEngine {
|
|||
}
|
||||
|
||||
impl Hash {
|
||||
/// Produces a hash from the current state of a given engine.
|
||||
pub fn from_engine(e: HashEngine) -> Hash { from_engine(e) }
|
||||
|
||||
/// Hashes the given data with an engine with the provided keys.
|
||||
pub fn hash_with_keys(k0: u64, k1: u64, data: &[u8]) -> Hash {
|
||||
let mut engine = HashEngine::with_keys(k0, k1);
|
||||
|
|
Loading…
Reference in New Issue