Trait kuchiki::traits::TendrilSink
[−]
[src]
pub trait TendrilSink<F, A = NonAtomic> where
A: Atomicity,
F: Format, { type Output; fn process(&mut self, t: Tendril<F, A>); fn error(&mut self, desc: Cow<'static, str>); fn finish(self) -> Self::Output; fn one<T>(self, t: T) -> Self::Output
where
T: Into<Tendril<F, A>>, { ... } fn from_iter<I>(self, i: I) -> Self::Output
where
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>, { ... } fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error>
where
F: SliceFormat<Slice = [u8]>,
R: Read, { ... } fn from_file<P>(self, path: P) -> Result<Self::Output, Error>
where
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>, { ... } }
Trait for types that can process a tendril.
This is a "push" interface, unlike the "pull" interface of
Iterator<Item=Tendril<F>>
. The push interface matches
html5ever and other incremental parsers with a similar
architecture.
Associated Types
type Output
What the overall result of processing is.
Required Methods
fn process(&mut self, t: Tendril<F, A>)
Process this tendril.
fn error(&mut self, desc: Cow<'static, str>)
Indicates that an error has occurred.
fn finish(self) -> Self::Output
Indicates the end of the stream.
Provided Methods
fn one<T>(self, t: T) -> Self::Output where
T: Into<Tendril<F, A>>,
T: Into<Tendril<F, A>>,
Process one tendril and finish.
fn from_iter<I>(self, i: I) -> Self::Output where
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
Consume an iterator of tendrils, processing each item, then finish.
fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
R: Read,
F: SliceFormat<Slice = [u8]>,
R: Read,
Read from the given stream of bytes until exhaustion and process incrementally,
then finish. Return Err
at the first I/O error.
fn from_file<P>(self, path: P) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,
Read from the file at the given path and process incrementally,
then finish. Return Err
at the first I/O error.
Implementations on Foreign Types
impl<Sink, A> TendrilSink<Bytes, A> for Utf8LossyDecoder<Sink, A> where
A: Atomicity,
Sink: TendrilSink<UTF8, A>,
[src]
A: Atomicity,
Sink: TendrilSink<UTF8, A>,
fn process(&mut self, t: Tendril<Bytes, A>)
[src]
fn error(&mut self, desc: Cow<'static, str>)
[src]
type Output = <Sink as TendrilSink<UTF8, A>>::Output
fn finish(self) -> <Sink as TendrilSink<UTF8, A>>::Output
[src]
fn one<T>(self, t: T) -> Self::Output where
T: Into<Tendril<F, A>>,
[src]
T: Into<Tendril<F, A>>,
fn from_iter<I>(self, i: I) -> Self::Output where
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
[src]
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
R: Read,
[src]
F: SliceFormat<Slice = [u8]>,
R: Read,
fn from_file<P>(self, path: P) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,
[src]
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,
impl<Sink> TendrilSink<UTF8, NonAtomic> for Parser<Sink> where
Sink: TreeSink,
[src]
Sink: TreeSink,
fn process(&mut self, t: Tendril<UTF8, NonAtomic>)
[src]
fn error(&mut self, desc: Cow<'static, str>)
[src]
type Output = <Sink as TreeSink>::Output
fn finish(self) -> <Parser<Sink> as TendrilSink<UTF8, NonAtomic>>::Output
[src]
fn one<T>(self, t: T) -> Self::Output where
T: Into<Tendril<F, A>>,
[src]
T: Into<Tendril<F, A>>,
fn from_iter<I>(self, i: I) -> Self::Output where
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
[src]
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
R: Read,
[src]
F: SliceFormat<Slice = [u8]>,
R: Read,
fn from_file<P>(self, path: P) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,
[src]
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,