CachingStream

Struct CachingStream 

Source
pub struct CachingStream<R>
where R: Read,
{ /* private fields */ }
Expand description

A wrapper around a Read that buffers and caches the data read in order to support searching with a regex.

Implementations§

Source§

impl<R> CachingStream<R>
where R: Read,

Source

pub fn new(r: R) -> Self

Source

pub fn clear_until(&self, offset: usize)

Clear the inner gap buffer state up until the end of the line before the given offset, tracking the historic line and byte counts so we can correctly adjust future read offsets.

Data before offset will no longer be accessible.

Trait Implementations§

Source§

impl<R> Debug for CachingStream<R>
where R: Read + Debug,

Source§

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

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

impl<R> Edit for CachingStream<R>
where R: Read,

Source§

fn insert(&mut self, ix: usize, s: &str)

Insert a string at the specified index
Source§

fn remove(&mut self, from: usize, to: usize)

Remove all characters from (from..to)
Source§

fn begin_edit_transaction(&mut self)

Mark the start of an edit transaction
Source§

fn end_edit_transaction(&mut self)

Mark the end of an edit transaction
Source§

impl<R> Haystack<Regex> for CachingStream<R>
where R: Read,

Source§

fn is_match_between(&self, re: &Regex, from: usize, to: usize) -> bool

Returns true if there is a match for the regex between the given byte offsets in the haystack. Read more
Source§

fn captures_between( &self, re: &Regex, from: usize, to: usize, ) -> Option<RawCaptures>

Searches for the first match of this regex between the given byte offsets in the given haystack, returning the overall match along with the matches of each capture group in the regex. If no match is found, then None is returned. Read more
Source§

impl<R> Haystack for CachingStream<R>
where R: Read,

Source§

fn try_make_contiguous(&mut self)

Source§

fn is_contiguous(&self) -> bool

Source§

fn len(&self) -> usize

Source§

fn substr_from<'a>(&'a self, byte_offset: usize) -> Option<Cow<'a, str>>

Source§

fn substr<'a>(&'a self, byte_from: usize, byte_to: usize) -> Cow<'a, str>

Source§

fn byte_to_char(&self, byte_idx: usize) -> Option<usize>

Source§

fn char_to_byte(&self, char_idx: usize) -> Option<usize>

Source§

fn iter_from(&self, from: usize) -> Option<impl Iterator<Item = (usize, char)>>

Source§

fn iter_between( &self, from: usize, to: usize, ) -> impl Iterator<Item = (usize, char)>

Source§

fn rev_iter_between( &self, _from: usize, _to: usize, ) -> impl Iterator<Item = (usize, char)>

Source§

impl<R> Sliceable for CachingStream<R>
where R: Read,

Source§

type Slice<'h> = StreamSlice<'h, R> where Self: 'h

The output of the slice method.
Source§

fn char_at(&self, byte_offset: usize) -> Option<char>

Returns the character at the given byte offset if one exists, otherwise None.
Source§

fn slice(&self, range: Range<usize>) -> Self::Slice<'_>

The contiguous sub-section of self that is denoted by the given byte Range.
Source§

fn max_len(&self) -> usize

The maximum length in bytes. Read more
Source§

impl<R> Writable for CachingStream<R>
where R: Read,

Source§

fn write_to<W>(&self, w: &mut W) -> Result<usize>
where W: Write,

Writes self to the given io::Write, returning the number of bytes written.

Auto Trait Implementations§

§

impl<R> !Freeze for CachingStream<R>

§

impl<R> !RefUnwindSafe for CachingStream<R>

§

impl<R> Send for CachingStream<R>
where R: Send,

§

impl<R> !Sync for CachingStream<R>

§

impl<R> Unpin for CachingStream<R>
where R: Unpin,

§

impl<R> UnwindSafe for CachingStream<R>
where R: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more