Skip to main content

StrInput

Struct StrInput 

Source
pub struct StrInput<'a> { /* private fields */ }
Expand description

A parser input that uses a &str as source.

Implementations§

Source§

impl<'a> StrInput<'a>

Source

pub fn new(input: &'a str) -> Self

Create a new StrInput with the given str.

Trait Implementations§

Source§

impl<'a> BorrowedInput<'a> for StrInput<'a>

Source§

fn slice_borrowed(&self, start: usize, end: usize) -> Option<&'a str>

Return a borrowed slice of the underlying source between two byte offsets. Read more
Source§

impl Input for StrInput<'_>

Source§

fn next_is_alpha(&self) -> bool

Check if the next character is an ASCII alphanumeric, _, or -.

This is used as a heuristic for error detection (e.g., when : is followed by tab and then a potential value character). The ASCII-only check is intentional: it catches common cases like key:\tvalue while avoiding false positives for valid YAML constructs. Unicode value starters (e.g., äöü) are not detected, but such cases will still fail to parse (with a less specific error message).

Source§

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

Fetch characters matching is_alpha (ASCII alphanumeric, _, -).

This is used for scanning tag handles (e.g., !foo!). Per YAML 1.2 spec, tag handles use ns-word-char which is [0-9a-zA-Z-]. Our implementation is slightly more permissive by also accepting _, but this is harmless and matches common practice. Unicode characters like ä or π are NOT valid in tag handles per spec, so the ASCII-only byte-based scanning here is both correct and efficient.

Source§

fn lookahead(&mut self, x: 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 buf_is_empty(&self) -> bool

Return whether the buffer (!= stream) is empty.
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 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 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 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_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<'a> Freeze for StrInput<'a>

§

impl<'a> RefUnwindSafe for StrInput<'a>

§

impl<'a> Send for StrInput<'a>

§

impl<'a> Sync for StrInput<'a>

§

impl<'a> Unpin for StrInput<'a>

§

impl<'a> UnsafeUnpin for StrInput<'a>

§

impl<'a> UnwindSafe for StrInput<'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> 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.