Skip to main content

IoWriter

Struct IoWriter 

Source
pub struct IoWriter<W: Write> { /* private fields */ }
Expand description

Buffered adapter that lets any std::io::Write act as a Writer.

Errors are sticky: the first failure stops all further output and is returned by IoWriter::finish. Buffered bytes are only written by IoWriter::finish or IoWriter::into_result; dropping the adapter discards them.

Implementations§

Source§

impl<W: Write> IoWriter<W>

Source

pub fn new(inner: W) -> Self

Source

pub fn with_capacity(capacity: usize, inner: W) -> Self

Source

pub fn finish(self) -> Result<W>

Flushes the buffer and returns the wrapped writer, or the first error that occurred.

Source

pub fn into_result(self) -> Result<()>

Trait Implementations§

Source§

impl<W: Write> Writer for IoWriter<W>

Source§

fn write(&mut self, bytes: &[u8])

Source§

fn write_byte(&mut self, byte: u8)

Source§

fn write_with(&mut self, len: usize, fill: impl FnOnce(&mut [u8]) -> usize)

Hands the sink a scratch region of len bytes, keeps the first fill(region) bytes of it and discards the rest.
Source§

fn reserve(&mut self, _additional: usize)

Auto Trait Implementations§

§

impl<W> !RefUnwindSafe for IoWriter<W>

§

impl<W> !UnwindSafe for IoWriter<W>

§

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

§

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

§

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

§

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

§

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.