pub trait FsExt<R: Runtime> {
// Required methods
fn fs_scope(&self) -> Scope;
fn try_fs_scope(&self) -> Option<Scope>;
fn fs(&self) -> &Fs<R>;
}Expand description
Extension trait implemented by every Manager (the app handle, windows, webviews, …)
to access the file system plugin APIs.
§Examples
use std::path::Path;
use tauri::Runtime;
use tauri_plugin_fs::FsExt;
fn setup<R: Runtime>(app: &tauri::App<R>) -> Result<(), Box<dyn std::error::Error>> {
// allow the app to access a directory that is not part of the static scope
app.fs_scope().allow_directory(Path::new("/path/to/directory"), true)?;
let contents = app.fs().read_to_string(Path::new("/path/to/directory/file.txt"))?;
println!("{contents}");
Ok(())
}Required Methods§
Sourcefn fs_scope(&self) -> Scope
fn fs_scope(&self) -> Scope
Returns the file system scope, which can be used to dynamically allow or deny paths at runtime.
§Panics
Panics if the plugin is not registered in the app.
Use FsExt::try_fs_scope if the plugin might not be registered.
Sourcefn try_fs_scope(&self) -> Option<Scope>
fn try_fs_scope(&self) -> Option<Scope>
Returns the file system scope, or None if the plugin is not registered in the app.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".