Skip to main content

StreamParser

Struct StreamParser 

Source
pub struct StreamParser<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> StreamParser<'a>

Source

pub fn new<T: AsRef<Path>>(file_path: T, value: &'a str) -> Self

Source

pub fn file_path(&self) -> &Path

Get the file path containing the current text.

Source

pub fn index(&self) -> usize

Get the current index.

Source

pub fn set_index(&mut self, index: usize)

Set the current index.

Source

pub fn next(&self) -> Result<char>

Returns the next byte without advancing the index.

§Errors

Returns an error if EOI is found.

Source

pub fn take_next(&mut self) -> Result<char>

Returns the next byte while advancing the index.

§Errors

Returns an error if EOI is found.

Source

pub fn peek(&self, n: usize) -> Result<&'a str>

Peek the next n bytes.

§Errors

Returns an error if EOI is found.

Source

pub fn peek_exact(&self, val: &str) -> bool

Returns if the next bytes match the provided value.

If EOI is reached, false is returned.

Source

pub fn peek_early(&self, n: usize, e: usize) -> Result<&'a str>

Peek the next n bytes starting at e bytes from the current index.

§Errors

Returns an error if EOI is found.

Source

pub fn peek_early_exact(&self, val: &str, e: usize) -> bool

Returns if the next bytes starting at e from the current index match the provided value.

If EOI is reached, false is returned.

Source

pub fn take(&mut self, n: usize) -> Result<()>

Advance the index of the stream of n bytes.

§Errors

Returns an error if EOI is found.

Source

pub fn take_exact(&mut self, val: &str) -> Result<()>

Check if the next characters match the value. If the values match, advance the current index of the length of the value and return true, otherwise return false.

§Errors

Returns an error if EOI is found or if the next characters does not match the string given as argument.

Source

pub fn trim(&mut self)

Advance the string so that the index will point to a non-space character.

Source

pub fn is_eoi(&self) -> bool

Source

pub fn get_range(&self, range: Range<usize>) -> Result<&'a str>

Get a range of text in the inner content.

§Errors

Returns an error if EOI is found.

Source

pub fn take_while<F: FnMut((usize, char)) -> bool>(&mut self, f: F) -> &'a str

Source

pub fn take_while_peekable<F: FnMut(usize, char, Option<char>) -> bool>( &mut self, f: F, ) -> &'a str

Source

pub fn take_until(&mut self, val: &str) -> Result<&'a str>

Take all the data until val is found.

Returns the data taken.

§Errors

Returns an error if EOI is found.

Source

pub fn take_until_index(&mut self, val: &str) -> Result<usize>

Take all the data until val is found.

Returns the index of the first character of val in the data.

§Errors

Returns an error if EOI is found.

Source

pub fn take_until_eoi(&mut self) -> &'a str

Trait Implementations§

Source§

impl<'a> Clone for StreamParser<'a>

Source§

fn clone(&self) -> StreamParser<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for StreamParser<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for StreamParser<'a>

§

impl<'a> RefUnwindSafe for StreamParser<'a>

§

impl<'a> Send for StreamParser<'a>

§

impl<'a> Sync for StreamParser<'a>

§

impl<'a> Unpin for StreamParser<'a>

§

impl<'a> UnsafeUnpin for StreamParser<'a>

§

impl<'a> UnwindSafe for StreamParser<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.