Struct tendril::stream::LossyDecoder
[−]
[src]
pub struct LossyDecoder<Sink, A = NonAtomic> where
Sink: TendrilSink<UTF8, A>,
A: Atomicity, { /* fields omitted */ }
A TendrilSink
adaptor that takes bytes, decodes them as the given character encoding,
lossily replace ill-formed byte sequences with U+FFFD replacement characters,
and emits Unicode (StrTendril
).
This allocates new tendrils for encodings other than UTF-8.
Methods
impl<Sink, A> LossyDecoder<Sink, A> where
Sink: TendrilSink<UTF8, A>,
A: Atomicity,
[src]
Sink: TendrilSink<UTF8, A>,
A: Atomicity,
fn new(encoding: EncodingRef, sink: Sink) -> LossyDecoder<Sink, A>
Create a new incremental decoder.
fn utf8(sink: Sink) -> LossyDecoder<Sink, A>
Create a new incremental decoder for the UTF-8 encoding.
This is useful for content that is known at run-time to be UTF-8
(whereas Utf8LossyDecoder
requires knowning at compile-time.)
fn inner_sink(&self) -> &Sink
Give a reference to the inner sink.
fn inner_sink_mut(&mut self) -> &mut Sink
Give a mutable reference to the inner sink.
Trait Implementations
impl<Sink, A> TendrilSink<Bytes, A> for LossyDecoder<Sink, A> where
Sink: TendrilSink<UTF8, A>,
A: Atomicity,
[src]
Sink: TendrilSink<UTF8, A>,
A: Atomicity,
fn process(&mut self, t: Tendril<Bytes, A>)
Process this tendril.
fn error(&mut self, desc: Cow<'static, str>)
Indicates that an error has occurred.
type Output = Sink::Output
What the overall result of processing is.
fn finish(self) -> Sink::Output
Indicates the end of the stream.
fn one<T>(self, t: T) -> Self::Output where
Self: Sized,
T: Into<Tendril<F, A>>,
Self: Sized,
T: Into<Tendril<F, A>>,
Process one tendril and finish.
fn from_iter<I>(self, i: I) -> Self::Output where
Self: Sized,
I: IntoIterator,
I::Item: Into<Tendril<F, A>>,
Self: Sized,
I: IntoIterator,
I::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> where
Self: Sized,
R: Read,
F: SliceFormat<Slice = [u8]>,
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. Read more
fn from_file<P>(self, path: P) -> Result<Self::Output> where
Self: Sized,
P: AsRef<Path>,
F: SliceFormat<Slice = [u8]>,
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. Read more