pub struct FileDialogBuilder<'a> { /* private fields */ }
Expand description
The file dialog builder.
Constructs file picker dialogs that can select single/multiple files or directories.
Implementations§
source§impl<'a> FileDialogBuilder<'a>
impl<'a> FileDialogBuilder<'a>
sourcepub fn set_default_path(&mut self, default_path: &'a Path) -> &mut Self
pub fn set_default_path(&mut self, default_path: &'a Path) -> &mut Self
Set starting file name or directory of the dialog.
sourcepub fn set_recursive(&mut self, recursive: bool) -> &mut Self
pub fn set_recursive(&mut self, recursive: bool) -> &mut Self
If directory is true, indicates that it will be read recursively later. Defines whether subdirectories will be allowed on the scope or not.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let _builder = FileDialogBuilder::new().set_recursive(true);
sourcepub fn set_title(&mut self, title: &'a str) -> &mut Self
pub fn set_title(&mut self, title: &'a str) -> &mut Self
Set the title of the dialog.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let _builder = FileDialogBuilder::new().set_title("Test Title");
sourcepub fn add_filter(
&mut self,
name: &'a str,
extensions: &'a [&'a str],
) -> &mut Self
pub fn add_filter( &mut self, name: &'a str, extensions: &'a [&'a str], ) -> &mut Self
Add file extension filter. Takes in the name of the filter, and list of extensions
§Example
use tauri_sys::dialog::FileDialogBuilder;
let _builder = FileDialogBuilder::new().add_filter("Image", &["png", "jpeg"]);
sourcepub fn add_filters(
&mut self,
filters: impl IntoIterator<Item = (&'a str, &'a [&'a str])>,
) -> &mut Self
pub fn add_filters( &mut self, filters: impl IntoIterator<Item = (&'a str, &'a [&'a str])>, ) -> &mut Self
Add many file extension filters.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let _builder = FileDialogBuilder::new().add_filters(&[("Image", &["png", "jpeg"]),("Video", &["mp4"])]);
sourcepub async fn pick_file(&self) -> Result<Option<PathBuf>, Error>
pub async fn pick_file(&self) -> Result<Option<PathBuf>, Error>
Shows the dialog to select a single file.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let file = FileDialogBuilder::new().pick_file().await?;
Requires allowlist > dialog > open
to be enabled.
sourcepub async fn pick_files(
&mut self,
) -> Result<Option<impl Iterator<Item = PathBuf>>, Error>
pub async fn pick_files( &mut self, ) -> Result<Option<impl Iterator<Item = PathBuf>>, Error>
Shows the dialog to select multiple files.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let files = FileDialogBuilder::new().pick_files().await?;
Requires allowlist > dialog > open
to be enabled.
sourcepub async fn pick_folder(&mut self) -> Result<Option<PathBuf>, Error>
pub async fn pick_folder(&mut self) -> Result<Option<PathBuf>, Error>
Shows the dialog to select a single folder.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let files = FileDialogBuilder::new().pick_folder().await?;
Requires allowlist > dialog > open
to be enabled.
sourcepub async fn pick_folders(
&mut self,
) -> Result<Option<impl Iterator<Item = PathBuf>>, Error>
pub async fn pick_folders( &mut self, ) -> Result<Option<impl Iterator<Item = PathBuf>>, Error>
Shows the dialog to select multiple folders.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let files = FileDialogBuilder::new().pick_folders().await?;
Requires allowlist > dialog > open
to be enabled.
sourcepub async fn save(&self) -> Result<Option<PathBuf>, Error>
pub async fn save(&self) -> Result<Option<PathBuf>, Error>
Open a file/directory save dialog.
The selected path is added to the filesystem and asset protocol allowlist scopes. When security is more important than the easy of use of this API, prefer writing a dedicated command instead.
Note that the allowlist scope change is not persisted, so the values are cleared when the application is restarted. You can save it to the filesystem using tauri-plugin-persisted-scope.
§Example
use tauri_sys::dialog::FileDialogBuilder;
let file = FileDialogBuilder::new().save().await?;
Requires allowlist > dialog > save
to be enabled.
Trait Implementations§
source§impl<'a> Clone for FileDialogBuilder<'a>
impl<'a> Clone for FileDialogBuilder<'a>
source§fn clone(&self) -> FileDialogBuilder<'a>
fn clone(&self) -> FileDialogBuilder<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for FileDialogBuilder<'a>
impl<'a> Debug for FileDialogBuilder<'a>
source§impl<'a> Default for FileDialogBuilder<'a>
impl<'a> Default for FileDialogBuilder<'a>
source§fn default() -> FileDialogBuilder<'a>
fn default() -> FileDialogBuilder<'a>
source§impl<'a> Hash for FileDialogBuilder<'a>
impl<'a> Hash for FileDialogBuilder<'a>
Auto Trait Implementations§
impl<'a> Freeze for FileDialogBuilder<'a>
impl<'a> RefUnwindSafe for FileDialogBuilder<'a>
impl<'a> Send for FileDialogBuilder<'a>
impl<'a> Sync for FileDialogBuilder<'a>
impl<'a> Unpin for FileDialogBuilder<'a>
impl<'a> UnwindSafe for FileDialogBuilder<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)