#[non_exhaustive]pub struct FileRequest {
pub kind: ChooseKind,
pub title: String,
pub directory: Option<PathBuf>,
pub purpose: Option<String>,
pub force_directory: bool,
pub file_name: Option<String>,
pub filters: Vec<FileFilter>,
pub confirm_overwrite: bool,
pub group_files: bool,
pub choices: Vec<FileChoice>,
}Expand description
What a choice asks for. Built with its constructors (FileRequest::open
and the others) and their builders: a field added later breaks nobody.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: ChooseKind§title: StringThe chooser’s title.
directory: Option<PathBuf>Where it starts (the last recent place, else home, by default).
With a purpose, only until that purpose has a
last folder, unless force_directory said
otherwise.
purpose: Option<String>The key the last folder is remembered under. See
FileRequest::purpose.
force_directory: booldirectory wins over the purpose’s last folder. See
FileRequest::force_directory.
file_name: Option<String>The name proposed when saving.
filters: Vec<FileFilter>§confirm_overwrite: boolSaving: the in-app picker asks before replacing an existing file
(on by default). See FileRequest::confirm_overwrite.
group_files: boolOpening files, the application’s groupings apply (on by default). See
FileRequest::ungrouped.
choices: Vec<FileChoice>The application’s options, shown beside the in-app picker’s buttons.
See FileRequest::choice.
Implementations§
Source§impl FileRequest
impl FileRequest
pub fn directory(self, dir: impl Into<PathBuf>) -> Self
Sourcepub fn purpose(self, key: &str) -> Self
pub fn purpose(self, key: &str) -> Self
The choice’s purpose: its last folder is remembered under this key,
so an import and an export do not share one (Windows’ SetClientGuid,
the identifier of a macOS panel). The next choice of that purpose
starts there: directory is then the first-time
default (Windows’ SetDefaultFolder), and the start when the last
folder is gone, before home. Recent places stay global, and a purpose
does not start in them. Without a purpose nothing is remembered per
choice and directory always wins.
Sourcepub fn force_directory(self, dir: impl Into<PathBuf>) -> Self
pub fn force_directory(self, dir: impl Into<PathBuf>) -> Self
Always starts in dir (Windows’ SetFolder), over the purpose’s last
folder, which the choice still updates: for a request that names the
folder that matters this time, as a document’s own. When dir is gone,
the last folder, then home.
pub fn file_name(self, name: &str) -> Self
Sourcepub fn filter(self, name: &str, extensions: &[&str]) -> Self
pub fn filter(self, name: &str, extensions: &[&str]) -> Self
Adds a filter (the first is the one shown first).
Sourcepub fn confirm_overwrite(self, ask: bool) -> Self
pub fn confirm_overwrite(self, ask: bool) -> Self
Whether the in-app picker asks before replacing an existing file
(on by default, as Windows’ FOS_OVERWRITEPROMPT and GTK 4): off
for an application that asks itself. It holds for the in-app
picker only: the system’s choosers ask on their own, and rfd
has no way to tell them not to.
Sourcepub fn ungrouped(self) -> Self
pub fn ungrouped(self) -> Self
Every file is an entry of its own and a choice gives no groups, whatever
the application’s groupings (groups): for a choice that is after a
sidecar as much as a RAW. Saving and choosing a folder never group: a name
to save under must see every file it could replace.
Sourcepub fn choice(
self,
id: &str,
label: &str,
options: &[(&str, &str)],
default: &str,
) -> Self
pub fn choice( self, id: &str, label: &str, options: &[(&str, &str)], default: &str, ) -> Self
An option of the application’s, a combo box offering options
((id, label)) and starting on default: the in-app picker shows it
beside its buttons, and the choice gives back the value picked
(chosen_choices), as Windows’ customize interface, macOS’s accessory
view and the desktop portal’s choices do; an import’s “Only new
photos”, an export’s format. A request with choices opens the in-app
picker even where the system’s chooser is used: rfd cannot show them.
Sourcepub fn check(self, id: &str, label: &str, default: bool) -> Self
pub fn check(self, id: &str, label: &str, default: bool) -> Self
An option of the application’s as a check box, on or off at first; its
value is "true" or "false". See FileRequest::choice.
Sourcepub fn choice_defaults(&self) -> ChoiceValues
pub fn choice_defaults(&self) -> ChoiceValues
Each choice with the value it starts with.
Sourcepub fn choice_values(
&self,
values: &ChoiceValues,
) -> Result<ChoiceValues, String>
pub fn choice_values( &self, values: &ChoiceValues, ) -> Result<ChoiceValues, String>
values over the defaults, each checked: an unknown id or a value its
choice cannot take is refused.
pub fn to_json(&self) -> Json
pub fn from_json(json: &Json) -> Result<FileRequest, String>
Trait Implementations§
Source§impl Clone for FileRequest
impl Clone for FileRequest
Source§fn clone(&self) -> FileRequest
fn clone(&self) -> FileRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileRequest
impl Debug for FileRequest
Source§impl<'de> Deserialize<'de> for FileRequest
impl<'de> Deserialize<'de> for FileRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for FileRequest
impl PartialEq for FileRequest
Source§impl Serialize for FileRequest
impl Serialize for FileRequest
impl StructuralPartialEq for FileRequest
Auto Trait Implementations§
impl Freeze for FileRequest
impl RefUnwindSafe for FileRequest
impl Send for FileRequest
impl Sync for FileRequest
impl Unpin for FileRequest
impl UnsafeUnpin for FileRequest
impl UnwindSafe for FileRequest
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more