Skip to main content

StreamScanner

Struct StreamScanner 

Source
pub struct StreamScanner { /* private fields */ }
Expand description

A streaming scanner over one compiled pattern, or over a set.

Implementations§

Source§

impl StreamScanner

Source

pub fn new(pattern: Pattern) -> Self

Begin a streaming scan for pattern.

Source

pub fn with_shapes(pattern: Pattern, shapes: ShapeSet) -> Self

Begin a streaming scan for pattern under the shapes and kinds shapes declares, which decide token boundaries as they do for crate::scan_with_shapes: the stream finds the matches that scan finds over the whole input.

Source

pub fn over_set(set: PatternSet) -> Self

Begin a streaming scan for every member of set at once, each match tagged with its member. The stream commits under its most conservative member: a match commits once the decided prefix holds the longest span any member can make, nothing commits before the end where any member depends on the whole input, and a line’s end is no boundary where any member reads whitespace; one window serves them all.

Source

pub fn commits_early(&self) -> bool

Whether a match can commit before the stream ends. A pattern that depends on the whole input retains everything until Self::finish.

Source

pub fn base(&self) -> usize

The absolute offset of the first retained byte: everything before it is committed, and no later byte can reach it.

Source

pub fn retained(&self) -> usize

The bytes retained now.

Source

pub fn rebase(&mut self) -> usize

Count this stream’s offsets from its first retained byte rather than from where it began, and give how far they moved; a reader adds that to every offset reported after. A span’s offsets reach four GiB, so a stream that runs longer, as a file followed for days can, is rebased as it goes. Every committed match must have been drained first, since those carry the offsets from before.

§Panics

A committed match has not been drained.

Source

pub fn peak_retained(&self) -> usize

The most bytes retained at once so far.

Source

pub fn push(&mut self, chunk: &[u8])

Feed the next chunk of input. Matches that can no longer change are committed; the rest is retained for the following chunk.

Source

pub fn drain_committed(&mut self) -> Vec<Span>

The matches committed so far, handed over once: a later call returns only what was committed after it, and finish returns what it commits plus whatever was never drained.

Source

pub fn drain_committed_with_members(&mut self) -> Vec<(usize, Span)>

Self::drain_committed, each match with the set member that made it; 0 throughout for a stream over one pattern.

Source

pub fn finish(self) -> Vec<Span>

Finish the stream: scan the retained buffer and return every match not yet drained, in absolute offsets.

Source

pub fn finish_with_members(self) -> Vec<(usize, Span)>

Self::finish, each match with the set member that made it.

Auto Trait Implementations§

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.