Skip to main content

BufferedInput

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. Doing this directly with iterator adapters would require pulling in all of itertools for one method, so this structure keeps the buffering local.

Implementations§

Source§

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

Source

pub fn new(input: T) -> Self

Create a new BufferedInput over the given character iterator.

Trait Implementations§

Source§

impl<T: Iterator<Item = char>> BorrowedInput<'static> for BufferedInput<T>

BufferedInput does not support zero-copy slicing since it’s a streaming input without stable backing storage.

Source§

fn slice_borrowed(&self, _start: usize, _end: usize) -> Option<&'static str>

Return a borrowed slice of the underlying source between two byte offsets. Read more
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 maximum number of characters this input can buffer for lookahead.
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 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 characters.
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 lookahead buffer is empty.
Source§

fn byte_offset(&self) -> Option<usize>

Return the current byte offset in the underlying source, if available. Read more
Source§

fn slice_bytes(&self, _start: usize, _end: usize) -> Option<&str>

Return a borrowed slice of the underlying source between two byte offsets. Read more
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 up to the end of the current line. 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
Source§

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

Fetch characters as long as they satisfy is_yaml_non_space(c). Read more
Source§

fn fetch_plain_scalar_chunk( &mut self, out: &mut String, count: usize, flow_level_gt_0: bool, ) -> (bool, usize)

Fetch a chunk of plain scalar characters. 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> UnsafeUnpin for BufferedInput<T>
where T: UnsafeUnpin,

§

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.