pub struct AstBuilder { /* private fields */ }Expand description
An incremental consumer that pulls events directly into an arena.
Implementations§
Source§impl AstBuilder
impl AstBuilder
Sourcepub fn with_capacity(nodes: usize, depth: usize) -> Self
pub fn with_capacity(nodes: usize, depth: usize) -> Self
Reserve arena and open-container capacity for allocation reuse.
Sourcepub fn consume<'a>(
&mut self,
events: &mut impl Iterator<Item = Result<Event<'a>, StreamError>>,
budget: usize,
) -> Result<BuildProgress, StreamError>
pub fn consume<'a>( &mut self, events: &mut impl Iterator<Item = Result<Event<'a>, StreamError>>, budget: usize, ) -> Result<BuildProgress, StreamError>
Pull up to budget events, retaining construction state between calls.
A zero budget does no work. Reaching the exact budget does not probe the iterator for another event.
§Errors
Returns parser errors or StreamError::Unbalanced for malformed streams. A failed builder cannot be finished.
Sourcepub fn finish<S: AsRef<str>>(
self,
source: S,
) -> Result<Document<S>, StreamError>
pub fn finish<S: AsRef<str>>( self, source: S, ) -> Result<Document<S>, StreamError>
Attach the original source after the stream has ended. The buffer is moved, not copied.
§Errors
Returns StreamError::Unbalanced if consumption failed or has not reached EOF, or StreamError::InvalidRange for invalid source-backed values.
Trait Implementations§
Source§impl Debug for AstBuilder
impl Debug for AstBuilder
Auto Trait Implementations§
impl Freeze for AstBuilder
impl RefUnwindSafe for AstBuilder
impl Send for AstBuilder
impl Sync for AstBuilder
impl Unpin for AstBuilder
impl UnsafeUnpin for AstBuilder
impl UnwindSafe for AstBuilder
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