Trait WriteExt

Source
pub trait WriteExt: Write {
    // Provided methods
    fn write_buf<B>(&mut self, buf: B) -> Result<(), Self::Error>
       where B: Buf { ... }
    fn write_buf_all<B>(&mut self, buf: B) -> Result<(), Self::Error>
       where B: Buf { ... }
    fn flush(&mut self) -> Result<(), Self::Error> { ... }
    fn by_ref(&mut self) -> &mut Self
       where Self: Sized { ... }
    fn transaction(
        self,
        kind: WriteTransactionKind<'_>,
    ) -> WriteTransactionVariant<'_, Self>
       where Self: Sized { ... }
}
Expand description

Write bytes to a writer.

Extension trait for all Write types.

Provided Methods§

Source

fn write_buf<B>(&mut self, buf: B) -> Result<(), Self::Error>
where B: Buf,

Write buf to the writer advancing it appropriately.

Source

fn write_buf_all<B>(&mut self, buf: B) -> Result<(), Self::Error>
where B: Buf,

Write buf to the writer advancing it until all of it has been written.

This method will try to write buf repeatedly until either a) buf has no more data, b) an error occurs, c) the writer cannot accept any more bytes.

Source

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

Flush this writer ensuring all bytes reach their destination.

Source

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Create a “by reference” adapter that takes the current instance of Write by mutable reference.

Source

fn transaction( self, kind: WriteTransactionKind<'_>, ) -> WriteTransactionVariant<'_, Self>
where Self: Sized,

Available on crate feature alloc only.

Create a transaction that uses this writer.

This is a convenience wrapper for: WriteTransactionVariant::new()

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.

Implementors§

Source§

impl<T: Write + ?Sized> WriteExt for T