pub struct CaptureLevel<'capture, Position> { /* private fields */ }Expand description
One nesting level borrowed from a CaptureBuilder.
A producer can append atoms or groups and cannot state a path, a handle, or a denominator. Every operation consumes the level, and only a successful operation returns it, so a refused partial level cannot be finished.
Implementations§
Source§impl<Position: Clone> CaptureLevel<'_, Position>
impl<Position: Clone> CaptureLevel<'_, Position>
Sourcepub fn finish(self) -> CapturedInput
pub fn finish(self) -> CapturedInput
Finish this root level as one captured input.
The issued denominator is read from the builder’s retained position roster rather than accepted from the producer.
Sourcepub fn examined<ProducerRefusal>(
self,
position: Position,
) -> Result<Self, CaptureBuildRefusal<Position, ProducerRefusal>>
pub fn examined<ProducerRefusal>( self, position: Position, ) -> Result<Self, CaptureBuildRefusal<Position, ProducerRefusal>>
Charge one producer observation that does not become a captured token.
This is the work-budget seat for a producer that skips trivia or backtracks before it offers an atom or group.
§Errors
Returns CaptureBuildRefusal::Unbounded at the producer position where the work budget is spent.
Sourcepub fn atom<ProducerRefusal>(
self,
position: Position,
read: impl FnOnce(SpanHandle) -> Result<CapturedAtom, ProducerRefusal>,
) -> Result<Self, CaptureBuildRefusal<Position, ProducerRefusal>>
pub fn atom<ProducerRefusal>( self, position: Position, read: impl FnOnce(SpanHandle) -> Result<CapturedAtom, ProducerRefusal>, ) -> Result<Self, CaptureBuildRefusal<Position, ProducerRefusal>>
Append one non-group token after the producer reads its value.
The builder issues the path and handle before invoking read, so a producer refusal retains the exact handle whose source position is already in custody.
§Errors
Returns the bound or producer refusal established at this token.
Sourcepub fn group<ProducerRefusal>(
self,
position: Position,
delimiter: CapturedDelimiter,
fill: impl FnOnce(SpanHandle, CaptureLevel<'_, Position>) -> Result<CaptureLevel<'_, Position>, CaptureBuildRefusal<Position, ProducerRefusal>>,
) -> Result<Self, CaptureBuildRefusal<Position, ProducerRefusal>>
pub fn group<ProducerRefusal>( self, position: Position, delimiter: CapturedDelimiter, fill: impl FnOnce(SpanHandle, CaptureLevel<'_, Position>) -> Result<CaptureLevel<'_, Position>, CaptureBuildRefusal<Position, ProducerRefusal>>, ) -> Result<Self, CaptureBuildRefusal<Position, ProducerRefusal>>
Append one group and let the same builder own its nested level.
§Errors
Returns the first bound or producer refusal established in pre-order.