Trait std::hash::Hasher 1.0.0[−][src]
pub trait Hasher {
Show methods
fn finish(&self) -> u64;
fn write(&mut self, bytes: &[u8]);
fn write_u8(&mut self, i: u8) { ... }
fn write_u16(&mut self, i: u16) { ... }
fn write_u32(&mut self, i: u32) { ... }
fn write_u64(&mut self, i: u64) { ... }
fn write_u128(&mut self, i: u128) { ... }
fn write_usize(&mut self, i: usize) { ... }
fn write_i8(&mut self, i: i8) { ... }
fn write_i16(&mut self, i: i16) { ... }
fn write_i32(&mut self, i: i32) { ... }
fn write_i64(&mut self, i: i64) { ... }
fn write_i128(&mut self, i: i128) { ... }
fn write_isize(&mut self, i: isize) { ... }
}Expand description
trait,用于散列任意字节流。
Hasher 的实例通常表示在对数据进行哈希处理时更改的状态。
Hasher 提供了一个相当基本的接口,用于检索生成的哈希 (使用 finish),并将整数以及字节片写入实例 (使用 write 和 write_u8 等)。
大多数情况下,Hasher 实例与 Hash trait 结合使用。
这个 trait 不假设各种 write_* 方法是如何定义的,并且 Hash 的实现不应该假设它们以一种或另一种方式工作。
例如,您不能假设一个 write_u32 调用等同于 write_u8 的四个调用。
Examples
use std::collections::hash_map::DefaultHasher; use std::hash::Hasher; let mut hasher = DefaultHasher::new(); hasher.write_u32(1989); hasher.write_u8(11); hasher.write_u8(9); hasher.write(b"Huh?"); println!("Hash is {:x}!", hasher.finish());Run
Required methods
Provided methods
将单个 u128 写入此哈希器。
将单个 usize 写入此哈希器。
将单个 i128 写入此哈希器。
将单个 isize 写入此哈希器。