Struct dectree_rs::SignatureDecisionTree
source · pub struct SignatureDecisionTree<T>{ /* private fields */ }Expand description
Represents a decision tree that can be used to search for signatures. This is a tree structure that can be used to search for signatures in a binary blob. The tree is built by adding signatures to the tree and then searching for them.
use dectree_rs::SignatureDecisionTree;
let mut tree = SignatureDecisionTree::new();
tree.add_signature(vec![0x55, 0xe9, 0xd8, 0x01, 0xfe, 0xff, 0x32, 0x77, 0x89, 0x4f, 0x55], None, None);
tree.add_signature(vec![0x55, 0xe9, 0xd8, 0x01, 0xfe, 0xff, 0x32], None, None);
tree.add_signature(vec![0x55, 0xe9, 0xd8, 0x01, 0xfe, 0x00], None, None);
assert_eq!(tree.get_signature(vec![0x55, 0xe9, 0xd8, 0x01, 0xfe, 0xff, 0x32, 0x00, 0x99, 0x36, 0x5f, 0x21, 0xfd], None), Some(()));
assert_eq!(tree.get_signature(vec![0x55, 0xe9, 0xd8, 0x01, 0xfe, 0xff, 0x32], None), Some(()));
assert_eq!(tree.get_signature(vec![0x55, 0xe9, 0xd8, 0x01, 0xfe, 0x00], None), Some(()));
assert_eq!(tree.get_signature(vec![0x55], None), None);Implementations§
source§impl<T> SignatureDecisionTree<T>
impl<T> SignatureDecisionTree<T>
sourcepub fn add_signature(
&mut self,
bytes: Vec<u8>,
masks: Option<Vec<u8>>,
val: Option<T>
)
pub fn add_signature( &mut self, bytes: Vec<u8>, masks: Option<Vec<u8>>, val: Option<T> )
Add a signature to the search tree. If masks goes unspecified, it will be
assumed to be all ones vec![0xff; bytes.len()].
Additionally, you may specify val as the object to get back with
tree.get_signature().
Trait Implementations§
source§impl<T> Clone for SignatureDecisionTree<T>
impl<T> Clone for SignatureDecisionTree<T>
source§fn clone(&self) -> SignatureDecisionTree<T>
fn clone(&self) -> SignatureDecisionTree<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<T> Debug for SignatureDecisionTree<T>
impl<T> Debug for SignatureDecisionTree<T>
Auto Trait Implementations§
impl<T> Freeze for SignatureDecisionTree<T>
impl<T> !RefUnwindSafe for SignatureDecisionTree<T>
impl<T> !Send for SignatureDecisionTree<T>
impl<T> !Sync for SignatureDecisionTree<T>
impl<T> Unpin for SignatureDecisionTree<T>
impl<T> !UnwindSafe for SignatureDecisionTree<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more