Skip to main content

HashTable

Trait HashTable 

Source
pub trait HashTable {
    // Required methods
    fn calc(&self, field_name: &str) -> u32;
    fn find(&self, hash: u32) -> String;
    fn add(&mut self, field_name: &str) -> u32;
}
Expand description

Trait for hash table implementations

Required Methods§

Source

fn calc(&self, field_name: &str) -> u32

Calculate the hash for a field name

§Arguments
  • field_name - The field name to hash
§Returns

The hash value corresponding to the given field name

Source

fn find(&self, hash: u32) -> String

Find the field name for a given hash Returns a hex representation like [DEADBEEF] if not found

§Arguments
  • hash - The hash value to look up
§Returns

The field name corresponding to the given hash, or a hex string if not found

Source

fn add(&mut self, field_name: &str) -> u32

Add a field name to the lookup table and return its hash

§Arguments
  • field_name - The field name to add to the lookup table
§Returns

The hash value corresponding to the added field name

Implementors§

Source§

impl HashTable for FileHashTable

Implementation of the HashTable trait for FileHashTable This allows FileHashTable to be used wherever a HashTable is expected, providing methods to calculate hashes, find field names by hash, and add new field names to the lookup table