Skip to main content

FileDialog

Struct FileDialog 

Source
pub struct FileDialog {
    pub mode: FileDialogMode,
    pub multiple: bool,
    pub title: Option<String>,
    pub filters: Vec<FileFilter>,
    pub directory: Option<String>,
    pub file_name: Option<String>,
    pub tag: Value,
}
Expand description

An Open, Save or folder dialog, as an app asks for one.

Fields§

§mode: FileDialogMode§multiple: bool

More than one file or folder may be picked (Open and Folder).

§title: Option<String>

The dialog’s title, where the platform shows one.

§filters: Vec<FileFilter>

The file types offered, the first one chosen; none is any file.

§directory: Option<String>

The folder it opens in; the platform’s choice when absent.

§file_name: Option<String>

A Save dialog’s suggested name.

§tag: Value

Handed back on the files event, as a node’s tag is.

Implementations§

Source§

impl FileDialog

Source

pub fn open() -> Self

An Open dialog for one existing file.

Source

pub fn save() -> Self

A Save dialog.

Source

pub fn folder() -> Self

A folder picker.

Source

pub fn multiple(self) -> Self

Source

pub fn title(self, title: impl Into<String>) -> Self

Source

pub fn filter(self, name: impl Into<String>, extensions: &[&str]) -> Self

Offers the file type name, matching extensions (without the dot; one written with it is taken without). The first filter added is the one chosen when it opens.

Source

pub fn directory(self, dir: impl Into<String>) -> Self

Source

pub fn file_name(self, name: impl Into<String>) -> Self

Source

pub fn tag(self, tag: impl Into<Value>) -> Self

Source

pub fn to_value(&self) -> Value

The ask as plain data — {mode, multiple, title?, filters: [{name, extensions}], directory?, fileName?, tag} — what a Node host’s takeFileRequests hands out and a script’s request_files takes.

Source

pub fn from_value(v: &Value) -> Result<Self, String>

Reads the plain-data shape back, file_name or fileName alike. Err names what is wrong: an unknown mode, a filter without a name or with extensions that are not strings.

Trait Implementations§

Source§

impl Clone for FileDialog

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FileDialog

Source§

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

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

impl Default for FileDialog

Source§

fn default() -> Self

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

impl PartialEq for FileDialog

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FileDialog

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.