Skip to main content

WritableFolderStore

Trait WritableFolderStore 

Source
pub trait WritableFolderStore: Send + Sync {
    // Required methods
    fn write(&self, name: &str, contents: &[u8]) -> Result<(), FolderError>;
    fn read(&self, name: &str) -> Result<Vec<u8>, FolderError>;
    fn list(&self) -> Result<Vec<String>, FolderError>;
    fn remove(&self, name: &str) -> Result<(), FolderError>;
    fn is_writable(&self) -> bool;
    fn handle(&self) -> String;
}
Expand description

Synchronous, thread-safe access to a user-chosen writable folder.

Implementations are Send + Sync so a background thread can read and write without involving the UI thread. Treat it as a flat store of named files (directories are not exposed by list).

Required Methods§

Source

fn write(&self, name: &str, contents: &[u8]) -> Result<(), FolderError>

Writes (overwriting) the file name with contents.

Source

fn read(&self, name: &str) -> Result<Vec<u8>, FolderError>

Reads the file name.

Source

fn list(&self) -> Result<Vec<String>, FolderError>

Lists the immediate child file names (directories excluded).

Source

fn remove(&self, name: &str) -> Result<(), FolderError>

Removes the file name. Succeeds if it is already absent.

Source

fn is_writable(&self) -> bool

Cheaply probes whether the folder is writable right now (e.g. detects a read-only WebDAV mount that still granted a write permission).

Source

fn handle(&self) -> String

The durable handle (filesystem path / SAF tree URI) used to reopen this folder with open_writable_folder on a later run.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§