pub struct BinRegex {
    pub n_groups: usize,
    /* private fields */
}
Expand description

A compiled variation of regular expressions intended for searching binary data. A BinRegex can be used to search binary data for patterns

Fields§

§n_groups: usize

Implementations§

source§

impl BinRegex

source

pub fn new(pattern: &str) -> Result<BinRegex, String>

Compiles a binary regular expression. Once compiled, this object can be used repeatedly to search input buffers.

source

pub fn find<'a, T>(&'a self, input: &'a T) -> Option<BinMatch<'_, T>>where &'a T: BitIndexable, T: BitIndexable,

Searches for the first match in the input given, and if found returns a BinMatch object corresponding to the match. If no match is found, returns None.

Examples
 use bitutils2::{BinRegex, BitIndex};

 let input = vec![0x00, 0x0a, 0xbc, 0x00, 0x00, 0x00, 0xff, 0x00];

 let re1 = BinRegex::new("ABC_{8,}''").unwrap();
 let m1 = re1.find(&input).unwrap();
 assert_eq!(m1.span(), (BitIndex::new(1, 4), BitIndex::new(6, 2)));

 let re2 = BinRegex::new("ABC_{8,}'_").unwrap();
 assert_eq!(re2.find(&input), None);
source

pub fn find_iter<'a, T>(&'a self, input: &'a T) -> BinMatches<'a, T> where &'a T: BitIndexable, T: BitIndexable,

Returns an iterator that yields successive non-overlapping matches in the input buffer.

source

pub fn match_length<'a, T>(&'a self, input: &'a T) -> Option<BitIndex>where &'a T: BitIndexable,

source

pub fn captures<'a, T>(&'a self, input: &'a T) -> Option<BinCaptures<'_, T>>where &'a T: BitIndexable, T: BitIndexable,

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.