Skip to main content

AsyncFile

Trait AsyncFile 

Source
pub trait AsyncFile: Send {
    // Required methods
    fn write_all<'a>(
        &'a mut self,
        buf: &'a [u8],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
    fn read_exact<'a>(
        &'a mut self,
        buf: &'a mut [u8],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
    fn read_to_end<'a>(
        &'a mut self,
        buf: &'a mut Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'a>>;
    fn seek<'a>(
        &'a mut self,
        pos: SeekFrom,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'a>>;
    fn sync_all(&self) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>;
    fn shutdown(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>;
}
Expand description

Async file trait.

Required Methods§

Source

fn write_all<'a>( &'a mut self, buf: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Write all bytes to the file.

Source

fn read_exact<'a>( &'a mut self, buf: &'a mut [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>

Read to fill the buffer exactly.

Source

fn read_to_end<'a>( &'a mut self, buf: &'a mut Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'a>>

Read all bytes into a vector.

Source

fn seek<'a>( &'a mut self, pos: SeekFrom, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'a>>

Seek to a position.

Source

fn sync_all(&self) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>

Sync all data to disk.

Source

fn shutdown(&mut self) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>

Shutdown the file (for sockets).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§