pub struct Bytes<'i> { /* private fields */ }Expand description
Implementations§
Source§impl<'i> Bytes<'i>
impl<'i> Bytes<'i>
Sourcepub fn parse<P: Pattern>(&mut self, pattern: P) -> Option<&'i [u8]>
pub fn parse<P: Pattern>(&mut self, pattern: P) -> Option<&'i [u8]>
Tests pattern against the bytes at the current position.
If the pattern matches, the cursor is moved, and the matching bytes are returned.
Sourcepub fn parse_while<'b, P: Pattern>(
&'b mut self,
pattern: P,
) -> BytesMatchIterMut<'b, 'i, P>
pub fn parse_while<'b, P: Pattern>( &'b mut self, pattern: P, ) -> BytesMatchIterMut<'b, 'i, P>
Returns an iterator that repeatedly tests pattern against self until it stops matching.
Advancing the iterator also advances the cursor.
Sourcepub fn parse_delimited<L, R>(&mut self, left: L, right: R) -> Option<&'i [u8]>
pub fn parse_delimited<L, R>(&mut self, left: L, right: R) -> Option<&'i [u8]>
Extracts the byte slice delimited by the given patterns.
The cursor is set to right after the right match, and the bytes between the left and right matches are returned.
Returns None if left does not match.
Returns None if no match for right is found after left
Sourcepub fn take_until<P: Pattern>(&mut self, pattern: P) -> &'i [u8] ⓘ
pub fn take_until<P: Pattern>(&mut self, pattern: P) -> &'i [u8] ⓘ
Advances the cursor until the pattern matches or the end of the input is encountered.
The cursor is set right before the match, and the bytes leading up to the match are returned.
Sourcepub fn accept<P: Pattern>(&mut self, pattern: P) -> bool
pub fn accept<P: Pattern>(&mut self, pattern: P) -> bool
Tests the pattern against the bytes at the current position.
If the pattern matches, the cursor is moved and the function returns true.
Sourcepub fn peek<P: Pattern>(&mut self, pattern: P) -> bool
pub fn peek<P: Pattern>(&mut self, pattern: P) -> bool
Like Bytes::accept, but the cursor is not moved after a successful match.
Trait Implementations§
Source§impl Seek for Bytes<'_>
impl Seek for Bytes<'_>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)