ferroui_base/platform/storage/
file_picker_save_options.rs1use super::{FilePickerFileType, PickerOptions};
2use std::ops::{Deref, DerefMut};
3use std::rc::Rc;
4
5#[derive(Clone, Default)]
9pub struct FilePickerSaveOptions {
10 base: PickerOptions,
11 suggested_file_type: Option<Rc<FilePickerFileType>>,
12 default_extension: Option<String>,
13 file_type_choices: Option<Vec<Rc<FilePickerFileType>>>,
14 show_overwrite_prompt: Option<bool>,
15}
16
17impl Deref for FilePickerSaveOptions {
18 type Target = PickerOptions;
19
20 fn deref(&self) -> &PickerOptions {
21 &self.base
22 }
23}
24
25impl DerefMut for FilePickerSaveOptions {
26 fn deref_mut(&mut self) -> &mut PickerOptions {
27 &mut self.base
28 }
29}
30
31impl From<PickerOptions> for FilePickerSaveOptions {
32 fn from(base: PickerOptions) -> Self {
33 Self { base, ..Self::default() }
34 }
35}
36
37impl FilePickerSaveOptions {
38 pub fn new() -> Self {
40 Self::default()
41 }
42
43 pub fn suggested_file_type(&self) -> Option<&Rc<FilePickerFileType>> {
49 self.suggested_file_type.as_ref()
50 }
51
52 pub fn set_suggested_file_type(&mut self, value: Option<Rc<FilePickerFileType>>) {
53 self.suggested_file_type = value;
54 }
55
56 pub fn with_suggested_file_type(mut self, value: Rc<FilePickerFileType>) -> Self {
59 self.suggested_file_type = Some(value);
60 self
61 }
62
63 pub fn default_extension(&self) -> Option<&str> {
65 self.default_extension.as_deref()
66 }
67
68 pub fn set_default_extension(&mut self, value: Option<String>) {
69 self.default_extension = value;
70 }
71
72 pub fn with_default_extension(mut self, value: impl Into<String>) -> Self {
75 self.default_extension = Some(value.into());
76 self
77 }
78
79 pub fn file_type_choices(&self) -> Option<&[Rc<FilePickerFileType>]> {
82 self.file_type_choices.as_deref()
83 }
84
85 pub fn set_file_type_choices(&mut self, value: Option<Vec<Rc<FilePickerFileType>>>) {
86 self.file_type_choices = value;
87 }
88
89 pub fn with_file_type_choices(mut self, value: Vec<Rc<FilePickerFileType>>) -> Self {
92 self.file_type_choices = Some(value);
93 self
94 }
95
96 pub fn show_overwrite_prompt(&self) -> Option<bool> {
99 self.show_overwrite_prompt
100 }
101
102 pub fn set_show_overwrite_prompt(&mut self, value: Option<bool>) {
103 self.show_overwrite_prompt = value;
104 }
105
106 pub fn with_show_overwrite_prompt(mut self, value: bool) -> Self {
109 self.show_overwrite_prompt = Some(value);
110 self
111 }
112}