Struct BufferedInput

Source
pub struct BufferedInput<T: Iterator<Item = char>> { /* private fields */ }
Expand description

A wrapper around an Iterator of chars with a buffer.

The YAML scanner often needs some lookahead. With fully allocated buffers such as String or &str, this is not an issue. However, with streams, we need to have a way of peeking multiple characters at a time and sometimes pushing some back into the stream. There is no “easy” way of doing this without itertools. In order to avoid pulling the entierty of itertools for one method, we use this structure.

Implementations§

Source§

impl<T: Iterator<Item = char>> BufferedInput<T>

Source

pub fn new(input: T) -> Self

Create a new BufferedInput with the given input.

Trait Implementations§

Source§

impl<T: Iterator<Item = char>> Input for BufferedInput<T>

Source§

fn lookahead(&mut self, count: usize)

A hint to the input source that we will need to read count characters. Read more
Source§

fn buflen(&self) -> usize

Return the number of buffered characters in self.
Source§

fn bufmaxlen(&self) -> usize

Return the capacity of the buffer in self.
Source§

fn raw_read_ch(&mut self) -> char

Read a character from the input stream and return it directly. Read more
Source§

fn raw_read_non_breakz_ch(&mut self) -> Option<char>

Read a non-breakz a character from the input stream and return it directly. Read more
Source§

fn skip(&mut self)

Consume the next character.
Source§

fn skip_n(&mut self, count: usize)

Consume the next count character.
Source§

fn peek(&self) -> char

Return the next character, without consuming it. Read more
Source§

fn peek_nth(&self, n: usize) -> char

Return the n-th character in the buffer, without consuming it. Read more
Source§

fn buf_is_empty(&self) -> bool

Return whether the buffer (!= stream) is empty.
Source§

fn look_ch(&mut self) -> char

Look for the next character and return it. Read more
Source§

fn next_char_is(&self, c: char) -> bool

Return whether the next character in the input source is equal to c. Read more
Source§

fn nth_char_is(&self, n: usize, c: char) -> bool

Return whether the n-th character in the input source is equal to c. Read more
Source§

fn next_2_are(&self, c1: char, c2: char) -> bool

Return whether the next 2 characters in the input source match the given characters. Read more
Source§

fn next_3_are(&self, c1: char, c2: char, c3: char) -> bool

Return whether the next 3 characters in the input source match the given characters. Read more
Source§

fn next_is_document_indicator(&self) -> bool

Check whether the next characters correspond to a document indicator. Read more
Source§

fn next_is_document_start(&self) -> bool

Check whether the next characters correspond to a start of document. Read more
Source§

fn next_is_document_end(&self) -> bool

Check whether the next characters correspond to an end of document. Read more
Source§

fn skip_ws_to_eol( &mut self, skip_tabs: SkipTabs, ) -> (usize, Result<SkipTabs, &'static str>)

Skip yaml whitespace at most up to eol. Also skips comments. Advances the input. Read more
Source§

fn next_can_be_plain_scalar(&self, in_flow: bool) -> bool

Check whether the next characters may be part of a plain scalar. Read more
Source§

fn next_is_blank_or_break(&self) -> bool

Check whether the next character is a blank or a break. Read more
Source§

fn next_is_blank_or_breakz(&self) -> bool

Check whether the next character is a blank or a breakz. Read more
Source§

fn next_is_blank(&self) -> bool

Check whether the next character is a blank. Read more
Source§

fn next_is_break(&self) -> bool

Check whether the next character is a break. Read more
Source§

fn next_is_breakz(&self) -> bool

Check whether the next character is a breakz. Read more
Source§

fn next_is_z(&self) -> bool

Check whether the next character is a z. Read more
Source§

fn next_is_flow(&self) -> bool

Check whether the next character is a flow. Read more
Source§

fn next_is_digit(&self) -> bool

Check whether the next character is a digit. Read more
Source§

fn next_is_alpha(&self) -> bool

Check whether the next character is a letter. Read more
Source§

fn skip_while_non_breakz(&mut self) -> usize

Skip characters from the input until a breakz is found. Read more
Source§

fn skip_while_blank(&mut self) -> usize

Skip characters from the input while blanks are found. Read more
Source§

fn fetch_while_is_alpha(&mut self, out: &mut String) -> usize

Fetch characters from the input while we encounter letters and store them in out. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BufferedInput<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for BufferedInput<T>
where T: RefUnwindSafe,

§

impl<T> Send for BufferedInput<T>
where T: Send,

§

impl<T> Sync for BufferedInput<T>
where T: Sync,

§

impl<T> Unpin for BufferedInput<T>
where T: Unpin,

§

impl<T> UnwindSafe for BufferedInput<T>
where T: 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.