[][src]Struct patternscan::Matches

pub struct Matches<R: Read> {
    pub reader: R,
    pub pattern: Pattern,
    // some fields omitted
}

Iterator over locations of matches for a pattern found within a byte string.

This struct implements the actual logic for pattern matching, and is used by the scan and scan_first_match functions to locate matches. The values returned by the iterator are indices of locations of the pattern matches within the byte string produced by reader.

The byte string which the pattern should be searched against is read from reader in CHUNK_SIZE chunks, when required by the iterator.

Example Usage

use patternscan;
use std::io::Cursor;

let bytes = [0x10, 0x20, 0x30, 0x40];
let reader = Cursor::new(bytes);
let pattern = patternscan::Matches::from_pattern_str(reader, "20 30").unwrap();
let match_indices: Result<Vec<usize>, _> = pattern.collect();
let match_indices = match_indices.unwrap();

Fields

reader: R

Reader from which the byte string to search will be read.

pattern: Pattern

Pattern to search for in the byte string.

Implementations

impl<R: Read> Matches<R>[src]

pub fn from_pattern(mut reader: R, pattern: Pattern) -> Result<Self, Error>[src]

Create a new instance of Matches from an instance of Pattern.

reader should be some Read type which will produce a byte string to search. pattern should be a Pattern to search for.

pub fn from_pattern_str(reader: R, pattern: &str) -> Result<Self, Error>[src]

Create a new instance of Matches from a string pattern.

Trait Implementations

impl<R: Read> Iterator for Matches<R>[src]

type Item = Result<usize, Error>

The type of the elements being iterated over.

Auto Trait Implementations

impl<R> RefUnwindSafe for Matches<R> where
    R: RefUnwindSafe
[src]

impl<R> Send for Matches<R> where
    R: Send
[src]

impl<R> Sync for Matches<R> where
    R: Sync
[src]

impl<R> Unpin for Matches<R> where
    R: Unpin
[src]

impl<R> UnwindSafe for Matches<R> where
    R: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.