Struct flussab::ByteWriter[][src]

pub struct ByteWriter<'a> { /* fields omitted */ }

A buffered writer with deferred error checking.

This can be used like std::io::BufWriter, but like ByteReader this performs deferred error checking. This means that any call to write, will always succeed. IO errors that occur during writing will be reported during the next call to flush or check_io_error. Any data written after an IO error occured, before it is eventually reported, will be discarded.

Deferring error checks like this can result in a significant speed up for some usage patterns.

Implementations

impl<'a> ByteWriter<'a>[src]

pub fn from_write(write: impl Write + 'a) -> Self[src]

Creates a ByteWriter writing data to a Write instance.

pub fn from_boxed_dyn_write(write: Box<dyn Write + 'a>) -> Self[src]

Creates a ByteWriter writing data to a boxed Write instance.

pub fn flush_defer_err(&mut self)[src]

Flush the buffered data to the underlying Write instance, deferring IO errors.

pub fn write_all_defer_err(&mut self, buf: &[u8])[src]

Write a slice of bytes, deferring IO errors.

Both, write and write_all directly call this method. Unlike them, this does not return a #[must_use] value, making it clear that this cannot return an error.

pub fn check_io_error(&mut self) -> Result<()>[src]

Returns an encountered IO errors as Err(io_err).

This resets the stored IO error and returns Ok(()) if no IO error is stored.

Trait Implementations

impl<'a> Drop for ByteWriter<'a>[src]

impl<'a> Write for ByteWriter<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for ByteWriter<'a>

impl<'a> !Send for ByteWriter<'a>

impl<'a> !Sync for ByteWriter<'a>

impl<'a> Unpin for ByteWriter<'a>

impl<'a> !UnwindSafe for ByteWriter<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.