Trait html5ever::tendril::TendrilSink

source ·
pub trait TendrilSink<F, A = NonAtomic>
where F: Format, A: Atomicity,
{ type Output; // Required methods fn process(&mut self, t: Tendril<F, A>); fn error(&mut self, desc: Cow<'static, str>); fn finish(self) -> Self::Output; // Provided methods fn one<T>(self, t: T) -> Self::Output where Self: Sized, T: Into<Tendril<F, A>> { ... } fn from_iter<I>(self, i: I) -> Self::Output where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<Tendril<F, A>> { ... } fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error> where Self: Sized, R: Read, F: SliceFormat<Slice = [u8]> { ... } fn from_file<P>(self, path: P) -> Result<Self::Output, Error> where Self: Sized, P: AsRef<Path>, F: SliceFormat<Slice = [u8]> { ... } }
Expand description

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.

Required Associated Types§

source

type Output

What the overall result of processing is.

Required Methods§

source

fn process(&mut self, t: Tendril<F, A>)

Process this tendril.

source

fn error(&mut self, desc: Cow<'static, str>)

Indicates that an error has occurred.

source

fn finish(self) -> Self::Output

Indicates the end of the stream.

Provided Methods§

source

fn one<T>(self, t: T) -> Self::Output
where Self: Sized, T: Into<Tendril<F, A>>,

Process one tendril and finish.

source

fn from_iter<I>(self, i: I) -> Self::Output
where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<Tendril<F, A>>,

Consume an iterator of tendrils, processing each item, then finish.

source

fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error>
where Self: Sized, R: Read, F: SliceFormat<Slice = [u8]>,

Read from the given stream of bytes until exhaustion and process incrementally, then finish. Return Err at the first I/O error.

source

fn from_file<P>(self, path: P) -> Result<Self::Output, Error>
where Self: Sized, P: AsRef<Path>, F: SliceFormat<Slice = [u8]>,

Read from the file at the given path and process incrementally, then finish. Return Err at the first I/O error.

Implementors§

source§

impl<Sink, A> TendrilSink<Bytes, A> for Utf8LossyDecoder<Sink, A>
where Sink: TendrilSink<UTF8, A>, A: Atomicity,

§

type Output = <Sink as TendrilSink<UTF8, A>>::Output

source§

impl<Sink: TreeSink> TendrilSink<UTF8> for Parser<Sink>

§

type Output = <Sink as TreeSink>::Output