pub struct Reader<'a> { /* private fields */ }Expand description
Struct that allows formated reading.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
Sourcepub fn read_to(&mut self, s: &mut String, max: usize) -> Result<(), ArgError>
pub fn read_to(&mut self, s: &mut String, max: usize) -> Result<(), ArgError>
Read at most max chars to the given string.
Sourcepub fn read_all(&mut self, s: &mut String) -> Result<(), ArgError>
pub fn read_all(&mut self, s: &mut String) -> Result<(), ArgError>
Read all the remaining chars to the given string.
Sourcepub fn bytes_size_hint(&self) -> usize
pub fn bytes_size_hint(&self) -> usize
Gets the low estimate of the remaining bytes.
Sourcepub fn err_parse(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
pub fn err_parse(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
Creates parse error with the given message.
Sourcepub fn err_value(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
pub fn err_value(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
Creates value error with the given message.
Sourcepub fn map_err_peek(&self, e: ArgError) -> ArgError
pub fn map_err_peek(&self, e: ArgError) -> ArgError
Adds relevant information to the given error. The span will start at the next character.
Sourcepub fn err_parse_peek(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
pub fn err_parse_peek(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
Creates parse error with the given message. Span will start at the next character.
Sourcepub fn err_value_peek(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
pub fn err_value_peek(&self, msg: impl Into<Cow<'static, str>>) -> ArgError
Creates value error with the given message. Span will start at the next character.
Sourcepub fn expect(&mut self, s: &str) -> Result<(), ArgError>
pub fn expect(&mut self, s: &str) -> Result<(), ArgError>
Match the given string to the output. If it doesn’t match, return error.
Sourcepub fn skip_while(
&mut self,
f: impl FnMut(char) -> bool,
) -> Result<(), ArgError>
pub fn skip_while( &mut self, f: impl FnMut(char) -> bool, ) -> Result<(), ArgError>
Skips characters while the given function matches.
Sourcepub fn is_next_some(&mut self, c: char) -> Result<bool, ArgError>
pub fn is_next_some(&mut self, c: char) -> Result<bool, ArgError>
Checks if the next char is the given char. If yes, returns true and moves to the next position.
Sourcepub fn is_next(
&mut self,
p: impl FnOnce(Option<char>) -> bool,
) -> Result<bool, ArgError>
pub fn is_next( &mut self, p: impl FnOnce(Option<char>) -> bool, ) -> Result<bool, ArgError>
Checks if the next value matches the predicate. If yes, returns true and moves to the next position.
Sourcepub fn chars(&mut self) -> ReaderChars<'_, 'a> ⓘ
pub fn chars(&mut self) -> ReaderChars<'_, 'a> ⓘ
Gets iterator over chars.
Sourcepub fn parse<'f, T>(
&mut self,
fmt: &'f ReadFmt<'f>,
) -> Result<(T, Option<ArgError>), ArgError>where
T: FromRead,
pub fn parse<'f, T>(
&mut self,
fmt: &'f ReadFmt<'f>,
) -> Result<(T, Option<ArgError>), ArgError>where
T: FromRead,
Parses the next value.
Sourcepub fn trim_left(&mut self, fmt: &ReadFmt<'_>) -> Result<(), ArgError>
pub fn trim_left(&mut self, fmt: &ReadFmt<'_>) -> Result<(), ArgError>
Trims characters from the left side according to the given format.
Sourcepub fn trim_right(&mut self, fmt: &ReadFmt<'_>) -> Result<(), ArgError>
pub fn trim_right(&mut self, fmt: &ReadFmt<'_>) -> Result<(), ArgError>
Trims characters from the right side according to the given format.