Skip to main content

Scanner

Struct Scanner 

Source
pub struct Scanner<'a, B: BinaryView> { /* private fields */ }
Expand description

Pattern scanner over a BinaryView.

Implementations§

Source§

impl<'a, B: BinaryView> Scanner<'a, B>

Source

pub fn new(view: &'a B) -> Self

Creates a scanner for a binary view.

Source

pub fn finds_code(&self, pat: &[Atom], save: &mut [Offset]) -> bool

Returns true only when the pattern has exactly one code match.

Source

pub fn required_slots(&self, pat: &[Atom]) -> usize

Returns the minimum required save-slot buffer length for pat.

Allocate at least this many elements before calling Self::finds_code or Self::matches_code/Matches::next.

Patterns produced by pattern::parse and pattern! always require at least one slot because they include an implicit Save(0) base capture.

Source

pub fn prepare_pattern(&self, pat: &[Atom]) -> PreparedPattern

Prepares reusable scanner metadata for a parsed pattern.

Source

pub fn prepare_pattern_str( &self, source: &str, ) -> Result<PreparedPattern, ParsePatError>

Parses and prepares a pattern string for scanning.

This is slower than Self::prepare_pattern because it performs runtime text parsing and allocates atom storage on each call.

Source

pub fn finds_prepared(&self, pat: &PreparedPattern, save: &mut [Offset]) -> bool

Returns true only when a prepared pattern has exactly one code match.

Source

pub fn matches_prepared<'p>( &self, pat: &'p PreparedPattern, ) -> Matches<'a, 'p, B>

Returns an iterator-like matcher for a prepared pattern.

Source

pub fn matches_code<'p>(&self, pat: &'p [Atom]) -> Matches<'a, 'p, B>

Returns an iterator-like matcher for all code-range matches.

save buffers passed to Matches::next must be at least self.required_slots(pat) elements long.

Trait Implementations§

Source§

impl<'a, B: Clone + BinaryView> Clone for Scanner<'a, B>

Source§

fn clone(&self) -> Scanner<'a, B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, B: Debug + BinaryView> Debug for Scanner<'a, B>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, B: Copy + BinaryView> Copy for Scanner<'a, B>

Auto Trait Implementations§

§

impl<'a, B> Freeze for Scanner<'a, B>

§

impl<'a, B> RefUnwindSafe for Scanner<'a, B>
where B: RefUnwindSafe,

§

impl<'a, B> Send for Scanner<'a, B>
where B: Sync,

§

impl<'a, B> Sync for Scanner<'a, B>
where B: Sync,

§

impl<'a, B> Unpin for Scanner<'a, B>

§

impl<'a, B> UnsafeUnpin for Scanner<'a, B>

§

impl<'a, B> UnwindSafe for Scanner<'a, B>
where B: RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.