pub struct CharReader<R> { /* private fields */ }Expand description
Character Reader with peeking functionality It buffers lines internally. So if you parse a stream with that never ends with \n it will all be put into memory
Implementations§
Source§impl<R: Read> CharReader<R>
impl<R: Read> CharReader<R>
pub fn new(input: R) -> CharReader<R>
pub fn from_string<'n>(input: &String) -> CharReader<&'n [u8]>
pub fn has_read(&self) -> bool
Sourcepub fn peek_char(&mut self, pos: usize) -> Result<Option<char>, ParseError>
pub fn peek_char(&mut self, pos: usize) -> Result<Option<char>, ParseError>
Read a character. pos is 0 indexed
pub fn peek_string(&mut self, length: usize) -> Result<String, ParseError>
Sourcepub fn peek_string_from(
&mut self,
pos: usize,
length: usize,
) -> Result<String, ParseError>
pub fn peek_string_from( &mut self, pos: usize, length: usize, ) -> Result<String, ParseError>
Try to fill string with length bytes
pub fn peek_until( &mut self, op: fn(char) -> bool, ) -> Result<Option<String>, ParseError>
pub fn peek_until_from( &mut self, pos: usize, op: fn(char) -> bool, ) -> Result<Option<String>, ParseError>
Sourcepub fn peek_until_match_inclusive(
&mut self,
pattern: &str,
) -> Result<Option<String>, ParseError>
pub fn peek_until_match_inclusive( &mut self, pattern: &str, ) -> Result<Option<String>, ParseError>
Peek until matches or return None when not found
pub fn consume(&mut self, length: usize) -> Result<Option<()>, ParseError>
pub fn consume_char(&mut self) -> Result<Option<char>, ParseError>
Sourcepub fn consume_string(&mut self, length: usize) -> Result<String, ParseError>
pub fn consume_string(&mut self, length: usize) -> Result<String, ParseError>
Read {length} bytes returning a smaller string on EOF
Sourcepub fn consume_until_inclusive(
&mut self,
op: fn(char) -> bool,
) -> Result<String, ParseError>
pub fn consume_until_inclusive( &mut self, op: fn(char) -> bool, ) -> Result<String, ParseError>
Will read until eof or op is true including the true match
Sourcepub fn consume_until_exclusive(
&mut self,
op: fn(char) -> bool,
) -> Result<String, ParseError>
pub fn consume_until_exclusive( &mut self, op: fn(char) -> bool, ) -> Result<String, ParseError>
will read until eof or op is true excluding the character that matched
pub fn consume_until_match_inclusive( &mut self, pattern: &str, ) -> Result<String, ParseError>
Auto Trait Implementations§
impl<R> Freeze for CharReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for CharReader<R>where
R: RefUnwindSafe,
impl<R> Send for CharReader<R>where
R: Send,
impl<R> Sync for CharReader<R>where
R: Sync,
impl<R> Unpin for CharReader<R>where
R: Unpin,
impl<R> UnwindSafe for CharReader<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more