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<FolderEntry>, FolderError>;
fn remove(&self, name: &str) -> Result<(), FolderError>;
fn open_read(
&self,
name: &str,
) -> Result<Box<dyn FolderReader>, FolderError>;
fn open_write(
&self,
name: &str,
) -> Result<Box<dyn FolderWriter>, FolderError>;
fn is_writable(&self) -> bool;
fn handle(&self) -> String;
// Provided methods
fn display_name(&self) -> String { ... }
fn entry(&self, name: &str) -> Result<FolderEntry, FolderError> { ... }
}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§
Sourcefn write(&self, name: &str, contents: &[u8]) -> Result<(), FolderError>
fn write(&self, name: &str, contents: &[u8]) -> Result<(), FolderError>
Writes (overwriting) the file name with contents.
Sourcefn list(&self) -> Result<Vec<FolderEntry>, FolderError>
fn list(&self) -> Result<Vec<FolderEntry>, FolderError>
Lists the immediate child files with their display metadata (directories excluded).
Sourcefn remove(&self, name: &str) -> Result<(), FolderError>
fn remove(&self, name: &str) -> Result<(), FolderError>
Removes the file name. Succeeds if it is already absent.
Sourcefn open_read(&self, name: &str) -> Result<Box<dyn FolderReader>, FolderError>
fn open_read(&self, name: &str) -> Result<Box<dyn FolderReader>, FolderError>
Opens a chunked reader over the file name.
Sourcefn open_write(&self, name: &str) -> Result<Box<dyn FolderWriter>, FolderError>
fn open_write(&self, name: &str) -> Result<Box<dyn FolderWriter>, FolderError>
Opens a chunked writer that replaces the file name on
FolderWriter::finish.
Sourcefn is_writable(&self) -> bool
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).
Sourcefn handle(&self) -> String
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.
Provided Methods§
Sourcefn display_name(&self) -> String
fn display_name(&self) -> String
The folder’s name as the user would recognise it. The default derives it
from the last component of handle;
providers that know a nicer name (an SAF display name) override it.
Sourcefn entry(&self, name: &str) -> Result<FolderEntry, FolderError>
fn entry(&self, name: &str) -> Result<FolderEntry, FolderError>
Display metadata for one file, without reading it.
The default filters list; providers that
can stat a single file override it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".