Skip to main content

AsyncSink

Trait AsyncSink 

Source
pub trait AsyncSink {
    type Error;

    // Required method
    async fn write(&mut self, bytes: &[u8]) -> Result<(), Self::Error>;

    // Provided method
    async fn begin(&mut self, _file_size: u32) -> Result<(), Self::Error> { ... }
}
Available on crate feature async only.
Expand description

Where an async file’s bytes go: Sink, awaited.

Required Associated Types§

Source

type Error

Why a write failed.

Required Methods§

Source

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

Writes all of bytes, or fails.

§Errors

Whatever the sink cannot write.

Provided Methods§

Source

async fn begin(&mut self, _file_size: u32) -> Result<(), Self::Error>

The whole file’s length, as Sink::begin has it: only write_async calls this.

§Errors

Whatever stops the sink taking a file of that length.

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<S: AsyncSink + ?Sized> AsyncSink for &mut S

Source§

type Error = <S as AsyncSink>::Error

Source§

async fn begin(&mut self, file_size: u32) -> Result<(), S::Error>

Source§

async fn write(&mut self, bytes: &[u8]) -> Result<(), S::Error>

Implementors§

Source§

impl<W: Write> AsyncSink for EmbeddedIo<W>

Available on crate feature embedded-io-async and (crate features embedded-io-async or embedded-io) only.