Skip to main content

TextStream

Struct TextStream 

Source
pub struct TextStream<C> {
    pub chars: Vec<C>,
    pub pos: usize,
}
Expand description

A decoded character stream with a cursor for sequential reading.

C is the character type produced by the TextProvider.

Fields§

§chars: Vec<C>

All decoded characters.

§pos: usize

Current read position.

Implementations§

Source§

impl<C> TextStream<C>

Source

pub fn new(chars: Vec<C>) -> Self

Creates a new stream from a vector of decoded characters.

Source

pub fn next(&mut self) -> Option<&C>

Returns the next character and advances the cursor, or None if the stream is exhausted.

Source

pub fn peek(&self) -> Option<&C>

Returns the next character without advancing the cursor, or None if the stream is exhausted.

Source

pub fn skip(&mut self, n: usize)

Advances the cursor by n positions, clamped to the stream length.

Source

pub fn remaining(&self) -> &[C]

Returns a slice of all characters from the current position onward.

Source

pub fn is_at_end(&self) -> bool

Returns true if the cursor has reached the end of the stream.

Source

pub fn position(&self) -> usize

Returns the current cursor position.

Auto Trait Implementations§

§

impl<C> Freeze for TextStream<C>

§

impl<C> RefUnwindSafe for TextStream<C>
where C: RefUnwindSafe,

§

impl<C> Send for TextStream<C>
where C: Send,

§

impl<C> Sync for TextStream<C>
where C: Sync,

§

impl<C> Unpin for TextStream<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for TextStream<C>

§

impl<C> UnwindSafe for TextStream<C>
where C: UnwindSafe,

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, 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.