tauri_sys::dialog

Struct FileDialogBuilder

source
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>

source

pub fn new() -> Self

Gets the default file dialog builder.

source

pub fn set_default_path(&mut self, default_path: &'a Path) -> &mut Self

Set starting file name or directory of the dialog.

source

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);
source

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");
source

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"]);
source

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"])]);
source

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.

source

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.

source

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.

source

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.

source

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>

source§

fn clone(&self) -> FileDialogBuilder<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for FileDialogBuilder<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Default for FileDialogBuilder<'a>

source§

fn default() -> FileDialogBuilder<'a>

Returns the “default value” for a type. Read more
source§

impl<'a> Hash for FileDialogBuilder<'a>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> Serialize for FileDialogBuilder<'a>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.