Skip to main content

HashFeed

Struct HashFeed 

Source
pub struct HashFeed { /* private fields */ }
Expand description

An analyst-supplied multi-algorithm known-good / known-bad hash set.

Hashes are stored as lowercase hex strings, partitioned by algorithm (auto-detected by length). Lookups normalize case and surrounding whitespace.

Implementations§

Source§

impl HashFeed

Source

pub fn new(source_label: impl Into<String>) -> Self

An empty feed carrying a provenance label.

Source

pub fn name(&self) -> &str

The provenance label.

Source

pub fn insert_bad(&mut self, hash: &str) -> Result<(), FeedError>

Insert a known-bad hash (algorithm auto-detected).

Source

pub fn insert_good(&mut self, hash: &str) -> Result<(), FeedError>

Insert a known-good hash (algorithm auto-detected).

Source

pub fn lookup_bad(&self, hash: &str) -> Option<HashMatch>

Look up a known-bad hash, returning a HashMatch on a hit.

Source

pub fn is_known_good(&self, hash: &str) -> bool

True if the hash is in the known-good set (e.g. an NSRL subset).

Source

pub fn load_bad_from_file(&mut self, path: &Path) -> Result<usize, FeedError>

Load known-bad hashes from a text/CSV file (one per line; # comments and blank lines skipped; the first comma/tab/space-delimited field is taken). Returns the number of valid hashes ingested; malformed lines are skipped.

Source

pub fn load_good_from_file(&mut self, path: &Path) -> Result<usize, FeedError>

Load known-good hashes from a text/CSV file (same format as HashFeed::load_bad_from_file).

Source

pub fn bad_count(&self) -> usize

Total known-bad hashes across all algorithms.

Source

pub fn good_count(&self) -> usize

Total known-good hashes across all algorithms.

Trait Implementations§

Source§

impl Debug for HashFeed

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.