pub struct Parser<'a> { /* private fields */ }Expand description
Parses frames into node trees.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub const fn new(table: TokenTable<'a>) -> Self
pub const fn new(table: TokenTable<'a>) -> Self
A parser over table, at the default depth limit.
Sourcepub const fn with_max_depth(self, max_depth: usize) -> Self
pub const fn with_max_depth(self, max_depth: usize) -> Self
Set how deep a frame may nest.
Sourcepub const fn table(&self) -> TokenTable<'a>
pub const fn table(&self) -> TokenTable<'a>
The token table in use.
Sourcepub fn parse(&self, frame: &'a [u8]) -> Result<NodeRef<'a>, ParseError>
pub fn parse(&self, frame: &'a [u8]) -> Result<NodeRef<'a>, ParseError>
Parse one node from frame, requiring it to consume the whole buffer.
The whole tree is validated here, so every accessor on the result is infallible.
Sourcepub fn parse_prefix(
&self,
frame: &'a [u8],
) -> Result<(NodeRef<'a>, &'a [u8]), ParseError>
pub fn parse_prefix( &self, frame: &'a [u8], ) -> Result<(NodeRef<'a>, &'a [u8]), ParseError>
Parse the first node in frame, allowing bytes to follow.
Useful when a caller frames several nodes back to back and wants to handle the remainder itself.
Trait Implementations§
impl<'a> Copy for Parser<'a>
impl<'a> Eq for Parser<'a>
impl<'a> StructuralPartialEq for Parser<'a>
Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnsafeUnpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'a>
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