Skip to main content

FileHandle

Trait FileHandle 

Source
pub trait FileHandle {
    // Required methods
    fn name(&self) -> &str;
    fn url(&self) -> String;
    fn size(&self) -> FileSizeFuture;
    fn read_at<'a>(
        &'a self,
        offset: u64,
        buf: &'a mut [u8],
    ) -> FileReadFuture<'a>;
    fn open_write(&self) -> Option<FileOpenFuture<Box<dyn FileWriter>>>;
}
Expand description

A picked file the system gives no path for, read and written at any offset.

Required Methods§

Source

fn name(&self) -> &str

The file’s name, which the user sees.

Source

fn url(&self) -> String

The URL the system reads the file by (PickedFile::url).

Source

fn size(&self) -> FileSizeFuture

Source

fn read_at<'a>(&'a self, offset: u64, buf: &'a mut [u8]) -> FileReadFuture<'a>

Reads into buf from offset; answers how many bytes it read, 0 at the end.

Source

fn open_write(&self) -> Option<FileOpenFuture<Box<dyn FileWriter>>>

Opens the file to write; None unless the pick is writable.

Implementations§

Source§

impl dyn FileHandle

Source

pub fn read_all(self: Box<Self>) -> ReadFileFuture

The whole file, from its start to its end, as Flutter’s XFile.readAsBytes reads a web pick. A picked path is read by the platform’s file service (Platform::files), not here: a handle reads itself, a path is only a name.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§