CharacterReader
struct · ferroui-base · v0.5.0
struct CharacterReader<'a>
A forward-only reader over a string.
Members
parse_argumentsparse_arguments_with_delimiternewendpeekpositiontakeskip_whitespacetake_iftake_if_strtake_if_fntake_untiltake_whiletry_peekpeek_whitespaceskipparse_identifierparse_type_identifierparse_numbercheck_keywordtake_if_keywordparse_style_class
parse_arguments
fn parse_arguments(self: &mut Self, open: char, close: char) -> Result<Vec<String>, ExpressionParseError>
Parses a list of arguments enclosed in open/close and separated by
,. The reader must be positioned on open.
parse_arguments_with_delimiter
fn parse_arguments_with_delimiter(self: &mut Self, open: char, close: char, delimiter: char) -> Result<Vec<String>, ExpressionParseError>
Parses a list of arguments enclosed in open/close and separated by
delimiter. The reader must be positioned on open.
new
fn new(s: &'a str) -> Self
Creates a reader positioned at the start of s.
end
fn end(self: &Self) -> bool
Gets a value indicating whether the whole input has been consumed.
peek
fn peek(self: &Self) -> Option<char>
Gets the next character without consuming it, or None at the end.
position
fn position(self: &Self) -> i32
Gets the number of characters consumed so far.
As upstream, Self::skip does not advance the position.
take
fn take(self: &mut Self) -> Option<char>
Consumes and returns the next character, or returns None at the end.
skip_whitespace
fn skip_whitespace(self: &mut Self)
Consumes leading white space.
take_if
fn take_if(self: &mut Self, c: char) -> bool
Consumes the next character if it equals c.
take_if_str
fn take_if_str(self: &mut Self, s: &str) -> bool
Consumes s if the remaining input starts with it.
take_if_fn
fn take_if_fn(self: &mut Self, condition: impl Fn(char) -> bool) -> bool
Consumes the next character if it satisfies condition.
take_until
fn take_until(self: &mut Self, c: char) -> &'a str
Consumes and returns everything up to (not including) the first c,
or the rest of the input when c does not occur.
take_while
fn take_while(self: &mut Self, condition: impl Fn(char) -> bool) -> &'a str
Consumes and returns the longest prefix whose characters all satisfy
condition.
try_peek
fn try_peek(self: &Self, count: usize) -> &'a str
Returns the next count characters without consuming them, or an empty
string when fewer than count characters remain.
peek_whitespace
fn peek_whitespace(self: &Self) -> &'a str
Returns the leading white space without consuming it.
skip
fn skip(self: &mut Self, count: usize)
Consumes count characters without advancing Self::position
(as upstream).
Panics
Panics when fewer than count characters remain; callers skip only
what they have peeked.
parse_identifier
fn parse_identifier(self: &mut Self) -> &'a str
Parses an identifier: a letter or _ followed by letters, _, marks,
connector punctuation, format characters and decimal digits. Returns an
empty string (consuming nothing) when the input does not start with an
identifier.
parse_type_identifier
fn parse_type_identifier(self: &mut Self) -> &'a str
Parses an identifier that may name a nested type, e.g. "Outer+Inner".
parse_number
fn parse_number(self: &mut Self) -> &'a str
Parses a run of decimal digits (possibly empty).
check_keyword
fn check_keyword(self: &Self, keyword: &str) -> bool
Checks whether the input continues with optional white space followed
by keyword, without consuming anything.
take_if_keyword
fn take_if_keyword(self: &mut Self, keyword: &str) -> bool
Consumes optional white space followed by keyword if the input
continues with it.
As upstream, the consumed characters are skipped without advancing
CharacterReader::position.
parse_style_class
fn parse_style_class(self: &mut Self) -> &'a str
Parses a style class name: an identifier that may also contain -.
Returns an empty string (consuming nothing) when the input does not
start with a class name.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherCloneDebug
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.