Skip to main content

Write

Trait Write 

Source
pub trait Write {
    type Error: Error;

    // Required methods
    async fn write(&mut self, buf: &[u8]) -> Result<usize, Error<Self::Error>>;
    async fn flush(&mut self) -> Result<(), Error<Self::Error>>;

    // Provided method
    async fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> { ... }
}
Available on crate feature async only.
Expand description

Asynchronously write bytes to a destination.

Required Associated Types§

Source

type Error: Error

Error returned by the destination.

Required Methods§

Source

async fn write(&mut self, buf: &[u8]) -> Result<usize, Error<Self::Error>>

Write some bytes.

Source

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

Flush buffered output.

Provided Methods§

Source

async fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Write all bytes, retrying interrupted operations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Write for &mut T
where T: Write + ?Sized,

Source§

type Error = <T as Write>::Error

Source§

async fn write( &mut self, buf: &[u8], ) -> Result<usize, Error<<&mut T as Write>::Error>>

Source§

async fn flush(&mut self) -> Result<(), Error<<&mut T as Write>::Error>>

Implementors§

Source§

impl<T> Write for Borrowed<'_, T>
where T: Write + ?Sized,

Source§

type Error = <T as Write>::Error

Source§

impl<T> Write for FromEmbedded<T>
where T: Write,