Struct flussab::ByteWriter [−][src]
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]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,