ferroui_base/platform/storage/
file_picker_open_options.rs1use super::{FilePickerFileType, PickerOptions};
2use std::ops::{Deref, DerefMut};
3use std::rc::Rc;
4
5#[derive(Clone, Default)]
9pub struct FilePickerOpenOptions {
10 base: PickerOptions,
11 suggested_file_type: Option<Rc<FilePickerFileType>>,
12 allow_multiple: bool,
13 file_type_filter: Option<Vec<Rc<FilePickerFileType>>>,
14}
15
16impl Deref for FilePickerOpenOptions {
17 type Target = PickerOptions;
18
19 fn deref(&self) -> &PickerOptions {
20 &self.base
21 }
22}
23
24impl DerefMut for FilePickerOpenOptions {
25 fn deref_mut(&mut self) -> &mut PickerOptions {
26 &mut self.base
27 }
28}
29
30impl From<PickerOptions> for FilePickerOpenOptions {
31 fn from(base: PickerOptions) -> Self {
32 Self { base, ..Self::default() }
33 }
34}
35
36impl FilePickerOpenOptions {
37 pub fn new() -> Self {
39 Self::default()
40 }
41
42 pub fn suggested_file_type(&self) -> Option<&Rc<FilePickerFileType>> {
48 self.suggested_file_type.as_ref()
49 }
50
51 pub fn set_suggested_file_type(&mut self, value: Option<Rc<FilePickerFileType>>) {
52 self.suggested_file_type = value;
53 }
54
55 pub fn with_suggested_file_type(mut self, value: Rc<FilePickerFileType>) -> Self {
58 self.suggested_file_type = Some(value);
59 self
60 }
61
62 pub fn allow_multiple(&self) -> bool {
65 self.allow_multiple
66 }
67
68 pub fn set_allow_multiple(&mut self, value: bool) {
69 self.allow_multiple = value;
70 }
71
72 pub fn with_allow_multiple(mut self, value: bool) -> Self {
75 self.allow_multiple = value;
76 self
77 }
78
79 pub fn file_type_filter(&self) -> Option<&[Rc<FilePickerFileType>]> {
81 self.file_type_filter.as_deref()
82 }
83
84 pub fn set_file_type_filter(&mut self, value: Option<Vec<Rc<FilePickerFileType>>>) {
85 self.file_type_filter = value;
86 }
87
88 pub fn with_file_type_filter(mut self, value: Vec<Rc<FilePickerFileType>>) -> Self {
91 self.file_type_filter = Some(value);
92 self
93 }
94}