Skip to main content

EncodedTextReader

Struct EncodedTextReader 

Source
pub struct EncodedTextReader { /* private fields */ }
Expand description

Text reader that decodes a byte reader with an explicit encoding.

This adapter currently decodes the complete byte input during construction and then serves text from memory. It is useful for bounded resources such as configuration files, database fields, and already-limited payloads.

Implementations§

Source§

impl EncodedTextReader

Source

pub fn new<R>( reader: R, encoding: &'static Encoding, policy: CodingErrorPolicy, ) -> Result<Self>
where R: Read,

Reads and decodes all bytes from reader.

§Parameters
  • reader: Byte reader to decode.
  • encoding: Encoding used by the byte reader.
  • policy: Malformed input handling policy.
§Returns

A text reader over the decoded content.

§Errors

Returns an I/O error when reading fails or when strict decoding finds malformed input bytes.

Source

pub fn into_inner(self) -> StringTextReader

Returns the inner decoded string reader.

§Returns

The decoded string reader.

Trait Implementations§

Source§

impl Debug for EncodedTextReader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TextLineRead for EncodedTextReader

Source§

fn read_line(&mut self, output: &mut String) -> Result<bool, Self::Error>

Reads one line into output. Read more
Source§

impl TextRead for EncodedTextReader

Source§

type Error = Error

Error returned by this text source.
Source§

fn read_char(&mut self) -> Result<Option<char>, Self::Error>

Reads the next Unicode scalar value. Read more
Source§

fn read_chars( &mut self, output: &mut Vec<char>, max: usize, ) -> Result<usize, Self::Error>

Reads up to max Unicode scalar values into output. Read more
Source§

fn read_to_string(&mut self, output: &mut String) -> Result<usize, Self::Error>

Reads all remaining text into output. Read more

Auto Trait Implementations§

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.