pub trait MatchTarget {
// Required methods
fn match_length(&self) -> usize;
fn subrange(&self, offset: usize, byte_count: usize) -> Option<&[u8]>;
fn translate_absolute_address(&self, address: u64) -> Option<usize>;
}Expand description
A trait for targets that can be matched against a binary pattern.
Implementing this trait allows matching against data sources that may not be
continuous (e.g., fragmented data or packed representations), offering greater flexibility
compared to directly using a u8 slice.
By default a u8 slice does implement this trait.
Required Methods§
Sourcefn match_length(&self) -> usize
fn match_length(&self) -> usize
Returns the total length of the data which will be scaned when matching a binary pattern.
Sourcefn subrange(&self, offset: usize, byte_count: usize) -> Option<&[u8]>
fn subrange(&self, offset: usize, byte_count: usize) -> Option<&[u8]>
Retrieves a subrange of the data, starting at the specified offset and spanning the given number of bytes.
§Parameters
offset: The starting position within the data.byte_count: The number of bytes to include in the subrange.
§Returns
An Option containing a slice of the data if the range is valid; otherwise, None.