pub trait WriteExt {
// Required methods
fn try_write_exact(
&mut self,
data: &[u8],
counter: impl FnMut(usize),
) -> Result<(), Error>;
fn try_fill(
&mut self,
len: usize,
counter: impl FnMut(usize),
) -> Result<(), Error>;
}
Expand description
An extension for Write
Required Methods§
Sourcefn try_write_exact(
&mut self,
data: &[u8],
counter: impl FnMut(usize),
) -> Result<(), Error>
fn try_write_exact( &mut self, data: &[u8], counter: impl FnMut(usize), ) -> Result<(), Error>
Tries to write data
completely and calls the position callback pos_cb
with the amount of
bytes written on every successful write
call
Note: This function behaves like write_exact
, except that you will never loose state in
case of an incomplete write - if the error is non-fatal (like TimedOut
), you can always
try again later from the last position as if nothing happened
Sourcefn try_fill(
&mut self,
len: usize,
counter: impl FnMut(usize),
) -> Result<(), Error>
fn try_fill( &mut self, len: usize, counter: impl FnMut(usize), ) -> Result<(), Error>
Tries to write len
zero bytes and calls the position callback pos_cb
with the amount of
bytes written on every successful write
call
Note: This function behaves similar to write_exact
(without data), except that you will
never loose state in case of an incomplete write - if the error is non-fatal (like
TimedOut
), you can always try again later if nothing happened
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.