Trait Write

Source
pub trait Write: MaybeSend {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn write_all<B: IoBuf>(
        &mut self,
        buf: B,
    ) -> impl Future<Output = (Result<(), Self::Error>, B)> + MaybeSend;
    fn flush(
        &mut self,
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;
    fn close(
        &mut self,
    ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;
}
Expand description

The core trait for writing data, it is similar to [std::io::Write], but it takes the ownership of the buffer, because completion-based IO requires the buffer to be pinned and should be safe to cancellation.

Write represents “sequential write all and overwrite” semantics, which means each buffer will be written to the file sequentially and overwrite the previous file when closed.

Contents are not be garanteed to be written to the file until the Write::close method is called, Write::flush may be used to flush the data to the file in some implementations, but not all implementations will do so.

Whether the operation is successful or not, the buffer will be returned, fusio promises that the returned buffer will be the same as the input buffer.

§Dyn Compatibility

This trait is not dyn compatible. If you want to use Write trait in a dynamic way, you could use DynWrite trait.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Required Methods§

Source

fn write_all<B: IoBuf>( &mut self, buf: B, ) -> impl Future<Output = (Result<(), Self::Error>, B)> + MaybeSend

Source

fn flush(&mut self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Source

fn close(&mut self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

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.

Implementations on Foreign Types§

Source§

impl<'write> Write for Box<dyn DynWrite + 'write>

Source§

type Error = Error

Source§

async fn write_all<B: IoBuf>(&mut self, buf: B) -> (Result<(), Self::Error>, B)

Source§

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

Source§

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

Source§

impl<W: Write> Write for &mut W

Source§

type Error = <W as Write>::Error

Source§

fn write_all<B: IoBuf>( &mut self, buf: B, ) -> impl Future<Output = (Result<(), Self::Error>, B)> + MaybeSend

Source§

fn flush(&mut self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Source§

fn close(&mut self) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Implementors§