[−][src]Trait kul_core::SourceStream
A stream of characters that might know its characters' positions in the source it is from.
It may be used with streaming sources that might consume or destroy the source and so can be iterated only once. Or it may be used with sources that can be iterated more than once by each time constructing new iterators that implement this trait.
It is able to accumulate its iterated items, when its next_accum
method is
called, until its accum_done
method is called, and this may be done
multiple times. The supertrait next
method will be called instead when
the next item must not be accumulated, as determined by first using the
peek
method to check, which is used to exclude escape characters from the
results of this crate's parsing.
After the next_accum
method has been called and returned some item, the
next
method should not be called before the accum_done
method is called,
to avoid interfering with a pending accumulation. If next
is called in
this case, the pending accumulation will be silently dropped.
Required methods
fn peek(&mut self) -> Option<&Self::Item>
Returns a reference to the next item's value without advancing the iterator and without interfering with any pending accumulation.
fn next_accum(
&mut self,
dalloc: &mut DA
) -> Result<Option<Self::Item>, AllocError>
&mut self,
dalloc: &mut DA
) -> Result<Option<Self::Item>, AllocError>
Get the next item, if any, and add it to a pending, or start a new, accumulation, and return the item.
When there is None
next item, any pending accumulation is preserved.
The DatumAllocator
argument may be used by some implementing types but
is often ignored. If ignored, the result should always be Ok
, else an
allocator error may be possible.
fn accum_done(&mut self, dalloc: &mut DA) -> Result<DA::TT, AllocError>
Take any pending accumulation and return it as a new text, or return an empty text if there was nothing pending.
The accumulation state is reset to nothing.
This is the primary constructor of the text values returned by the
Parser
s.
The DatumAllocator
argument may be used by some implementing types but
is often ignored. If ignored, the result should always be Ok
, else an
allocator error may be possible.
Implementors
impl<'l, TT, DA> SourceStream<DA> for Iter<'l, TT> where
TT: TextConcat<DA>,
TT::Chunk: 'l,
DA: DatumAllocator<TT = TT>,
[src]
TT: TextConcat<DA>,
TT::Chunk: 'l,
DA: DatumAllocator<TT = TT>,
SourceStream
is only implemented where a Text
type is a TextConcat
.
fn peek(&mut self) -> Option<&Self::Item>
[src]
fn next_accum(
&mut self,
dalloc: &mut DA
) -> Result<Option<Self::Item>, AllocError>
[src]
&mut self,
dalloc: &mut DA
) -> Result<Option<Self::Item>, AllocError>