Skip to main content

Files

Trait Files 

Source
pub trait Files {
    // Required methods
    fn read(&self, path: &Path) -> ReadFileFuture;
    fn write(&self, path: &Path, bytes: &[u8]) -> WriteFileFuture;
    fn open(&self, path: &Path, mode: OpenMode) -> OpenFileFuture;
    fn metadata(&self, path: &Path) -> FileMetadataFuture;
    fn list(&self, path: &Path) -> ListFilesFuture;
    fn create_folder(&self, path: &Path) -> FileOperationFuture;
    fn rename(&self, from: &Path, to: &Path) -> FileOperationFuture;
    fn delete(&self, path: &Path) -> FileOperationFuture;
}
Expand description

The host’s file system.

Required Methods§

Source

fn read(&self, path: &Path) -> ReadFileFuture

The whole file at path, as Flutter’s XFile.readAsBytes reads it.

Source

fn write(&self, path: &Path, bytes: &[u8]) -> WriteFileFuture

Writes bytes as the whole file at path, making it or replacing it.

Source

fn open(&self, path: &Path, mode: OpenMode) -> OpenFileFuture

Opens path as mode says; the file reads and writes at an offset and streams.

Source

fn metadata(&self, path: &Path) -> FileMetadataFuture

What the file or folder at path is.

Source

fn list(&self, path: &Path) -> ListFilesFuture

What is in the folder at path, in no particular order.

Source

fn create_folder(&self, path: &Path) -> FileOperationFuture

Makes an empty folder at path, and the folders above it where they are missing, as Dart’s Directory.create(recursive: true) does. A folder already there is left as it is.

Source

fn rename(&self, from: &Path, to: &Path) -> FileOperationFuture

Renames from to to, which may be in another folder.

Source

fn delete(&self, path: &Path) -> FileOperationFuture

Deletes the file or folder at path. A folder is deleted with what is in it, as Dart’s Directory.delete(recursive: true) on macOS and Linux does; a system that refuses a non-empty folder answers that refusal.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§