pub trait Streaming: Sized + Clone + Eq + Debug {
type Item: Debug;
type Error: Debug;
type Span: Debug + Streaming;
// Required methods
fn split_first(self) -> Split<Self::Item, Self, Self::Error>;
fn split_at(self, mid: usize) -> Split<Self::Span, Self, Self::Error>;
fn split_last(self) -> Split<Self::Item, Self, Self::Error>;
fn all(self) -> Result<Success<Self::Span, Self>, Self::Error>;
fn diff(self, other: &Self) -> Result<Self::Span, Self>;
// Provided method
fn consume(self) -> Self { ... }
}
Expand description
This trait must be implement by all struct that want to be a stream for binator.
Required Associated Types§
Required Methods§
sourcefn split_first(self) -> Split<Self::Item, Self, Self::Error>
fn split_first(self) -> Split<Self::Item, Self, Self::Error>
Will remove the first item from the stream
sourcefn split_at(self, mid: usize) -> Split<Self::Span, Self, Self::Error>
fn split_at(self, mid: usize) -> Split<Self::Span, Self, Self::Error>
Will split the stream in half
sourcefn split_last(self) -> Split<Self::Item, Self, Self::Error>
fn split_last(self) -> Split<Self::Item, Self, Self::Error>
Will remove the last item from the stream, not this is know as backtracking. It’s generally not recommanded to do this, not all stream will be able to implement this
Provided Methods§
sourcefn consume(self) -> Self
fn consume(self) -> Self
This should be used with maximum care. This is used to tell to the stream, “drop already read data”. It’s mean all data before the cursor of this stream is gone. It’s invalidate any Stream or Span with cursor that point to purged data. The purpose of this is to avoid keep all data in memory if not needed. This should be call only by end user parser or be documented properly.
Object Safety§
This trait is not object safe.