tendril::stream

Struct Utf8LossyDecoder

Source
pub struct Utf8LossyDecoder<Sink, A = NonAtomic>
where Sink: TendrilSink<UTF8, A>, A: Atomicity,
{ pub inner_sink: Sink, /* private fields */ }
Expand description

A TendrilSink adaptor that takes bytes, decodes them as UTF-8, lossily replace ill-formed byte sequences with U+FFFD replacement characters, and emits Unicode (StrTendril).

This does not allocate memory: the output is either subtendrils on the input, on inline tendrils for a single code point.

Fields§

§inner_sink: Sink

Implementations§

Source§

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

Source

pub fn new(inner_sink: Sink) -> Self

Create a new incremental UTF-8 decoder.

Trait Implementations§

Source§

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

Source§

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

What the overall result of processing is.
Source§

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

Process this tendril.
Source§

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

Indicates that an error has occurred.
Source§

fn finish(self) -> Sink::Output

Indicates the end of the stream.
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::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>
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>
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.

Auto Trait Implementations§

§

impl<Sink, A> Freeze for Utf8LossyDecoder<Sink, A>
where Sink: Freeze,

§

impl<Sink, A> RefUnwindSafe for Utf8LossyDecoder<Sink, A>
where Sink: RefUnwindSafe, A: RefUnwindSafe,

§

impl<Sink, A> Send for Utf8LossyDecoder<Sink, A>
where Sink: Send, A: Send,

§

impl<Sink, A> Sync for Utf8LossyDecoder<Sink, A>
where Sink: Sync, A: Sync,

§

impl<Sink, A> Unpin for Utf8LossyDecoder<Sink, A>
where Sink: Unpin, A: Unpin,

§

impl<Sink, A> UnwindSafe for Utf8LossyDecoder<Sink, A>
where Sink: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.