Skip to main content

EncodedTextWriter

Struct EncodedTextWriter 

Source
pub struct EncodedTextWriter<W> { /* private fields */ }
Expand description

Text writer that encodes Unicode text with an explicit encoding.

Implementations§

Source§

impl<W> EncodedTextWriter<W>
where W: Write,

Source

pub const fn new( inner: W, encoding: &'static Encoding, policy: CodingErrorPolicy, ) -> Self

Creates an encoded text writer.

§Parameters
  • inner: Byte writer to receive encoded bytes.
  • encoding: Encoding used for outgoing text.
  • policy: Unencodable text handling policy.
§Returns

A text writer using LF line endings.

Source

pub const fn with_line_ending(self, line_ending: LineEnding) -> Self

Sets the line ending for this writer.

§Parameters
  • line_ending: Line ending to use for subsequent lines.
§Returns

This writer with the configured line ending.

Source

pub const fn get_ref(&self) -> &W

Returns a shared reference to the wrapped byte writer.

§Returns

The wrapped byte writer.

Source

pub fn get_mut(&mut self) -> &mut W

Returns a mutable reference to the wrapped byte writer.

§Returns

The wrapped byte writer.

Source

pub fn into_inner(self) -> W

Returns the wrapped byte writer.

§Returns

The underlying byte writer.

Trait Implementations§

Source§

impl<W: Debug> Debug for EncodedTextWriter<W>

Source§

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

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

impl<W> TextWrite for EncodedTextWriter<W>
where W: Write,

Source§

type Error = Error

Error returned by this text sink.
Source§

fn line_ending(&self) -> LineEnding

Returns the configured line ending for TextWrite::write_line. Read more
Source§

fn write_char(&mut self, ch: char) -> Result<(), Self::Error>

Writes one Unicode scalar value. Read more
Source§

fn write_chars(&mut self, chars: &[char]) -> Result<(), Self::Error>

Writes a slice of Unicode scalar values. Read more
Source§

fn write_str(&mut self, text: &str) -> Result<(), Self::Error>

Writes a string slice. Read more
Source§

fn write_line(&mut self, line: &str) -> Result<(), Self::Error>

Writes a line followed by the configured line ending. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flushes buffered text to the underlying sink. Read more

Auto Trait Implementations§

§

impl<W> Freeze for EncodedTextWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for EncodedTextWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for EncodedTextWriter<W>
where W: Send,

§

impl<W> Sync for EncodedTextWriter<W>
where W: Sync,

§

impl<W> Unpin for EncodedTextWriter<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for EncodedTextWriter<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for EncodedTextWriter<W>
where W: 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.