Initial block model support

This commit is contained in:
Thinkofname 2016-03-24 15:39:57 +00:00
parent a42c1e412a
commit ce6f5c963c
3 changed files with 26 additions and 1 deletions

View File

@ -17,7 +17,7 @@ extern crate byteorder;
use std::fmt;
use protocol::Serializable;
use std::io;
use std::io::{Read, Write};
use std::io::Write;
use self::byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
#[derive(Clone, Copy)]

View File

@ -0,0 +1,24 @@
use std::hash::Hasher;
pub struct FNVHash(u64);
impl Hasher for FNVHash {
fn write(&mut self, bytes: &[u8]) {
for b in bytes {
self.0 = self.0.wrapping_mul(0x100000001b3);
self.0 ^= *b as u64
}
}
fn finish(&self) -> u64 {
self.0
}
}
impl Default for FNVHash {
fn default() -> Self {
FNVHash(0xcbf29ce484222325)
}
}

View File

@ -20,3 +20,4 @@ pub use self::metadata::*;
pub mod bit;
pub mod nibble;
pub mod hash;