pub struct StreamingMatcher<'r> { /* private fields */ }Expand description
A streaming matcher for incremental fuzzy regex matching.
This type maintains state across multiple feed() calls, allowing
matches to span chunk boundaries.
§Example
use fuzzy_regex::FuzzyRegex;
let re = FuzzyRegex::new("(?:hello){e<=1}").unwrap();
let mut stream = re.stream();
// Process data in chunks
for chunk in [b"hel".as_slice(), b"lo world".as_slice()] {
for m in stream.feed(chunk) {
println!("Found match at offset {}", m.start());
}
}Implementations§
Source§impl<'r> StreamingMatcher<'r>
impl<'r> StreamingMatcher<'r>
Sourcepub fn feed(&mut self, chunk: &[u8]) -> FeedMatches<'_> ⓘ
pub fn feed(&mut self, chunk: &[u8]) -> FeedMatches<'_> ⓘ
Feed a chunk of bytes into the matcher.
Returns an iterator over matches found in this chunk (including matches that span from the previous chunk).
Sourcepub fn finish(&mut self) -> Option<StreamingMatch>
pub fn finish(&mut self) -> Option<StreamingMatch>
Signal end of stream and return any final match.
Call this after all data has been fed to handle matches at the end of the stream.
Sourcepub fn position(&self) -> usize
pub fn position(&self) -> usize
Get the current position in the stream (total bytes processed).
Sourcepub fn search_reader<R: Read>(self, reader: R) -> ReaderMatches<'r, R> ⓘ
pub fn search_reader<R: Read>(self, reader: R) -> ReaderMatches<'r, R> ⓘ
Process a reader, yielding matches.
Reads the reader in chunks and yields matches as they are found.
§Example
use fuzzy_regex::FuzzyRegex;
use std::fs::File;
use std::io::BufReader;
let re = FuzzyRegex::new("(?:hello){e<=1}").unwrap();
let mut stream = re.stream();
let file = File::open("large_file.txt").unwrap();
for m in stream.search_reader(BufReader::new(file)) {
println!("Match at {}-{}", m.start(), m.end());
}Auto Trait Implementations§
impl<'r> Freeze for StreamingMatcher<'r>
impl<'r> !RefUnwindSafe for StreamingMatcher<'r>
impl<'r> !Send for StreamingMatcher<'r>
impl<'r> !Sync for StreamingMatcher<'r>
impl<'r> Unpin for StreamingMatcher<'r>
impl<'r> UnsafeUnpin for StreamingMatcher<'r>
impl<'r> !UnwindSafe for StreamingMatcher<'r>
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