odht 0.3.1

A Rust crate for hash tables that can be mapped from disk into memory without the need for up-front decoding.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::HashFn;
use std::convert::TryInto;

/// A hash function that simply takes the last 4 bytes of a given key as the
/// hash value.
#[derive(Eq, PartialEq)]
pub struct UnHashFn;

impl HashFn for UnHashFn {
    #[inline]
    fn hash(bytes: &[u8]) -> u32 {
        let len = bytes.len();
        u32::from_le_bytes(bytes[len - 4..].try_into().unwrap())
    }
}