Skip to main content

ferroui_base/platform/storage/
folder_picker_open_options.rs

1use super::PickerOptions;
2use std::ops::{Deref, DerefMut};
3
4/// Options class for the
5/// [`IStorageProvider::open_folder_picker_async`](super::IStorageProvider::open_folder_picker_async)
6/// method.
7#[derive(Clone, Default)]
8pub struct FolderPickerOpenOptions {
9    base: PickerOptions,
10    allow_multiple: bool,
11}
12
13impl Deref for FolderPickerOpenOptions {
14    type Target = PickerOptions;
15
16    fn deref(&self) -> &PickerOptions {
17        &self.base
18    }
19}
20
21impl DerefMut for FolderPickerOpenOptions {
22    fn deref_mut(&mut self) -> &mut PickerOptions {
23        &mut self.base
24    }
25}
26
27impl From<PickerOptions> for FolderPickerOpenOptions {
28    fn from(base: PickerOptions) -> Self {
29        Self { base, ..Self::default() }
30    }
31}
32
33impl FolderPickerOpenOptions {
34    /// Creates options with nothing set.
35    pub fn new() -> Self {
36        Self::default()
37    }
38
39    /// An option indicating whether the open picker allows users to select
40    /// multiple folders.
41    pub fn allow_multiple(&self) -> bool {
42        self.allow_multiple
43    }
44
45    pub fn set_allow_multiple(&mut self, value: bool) {
46        self.allow_multiple = value;
47    }
48
49    /// Sets [`allow_multiple`](Self::allow_multiple) and returns the
50    /// options.
51    pub fn with_allow_multiple(mut self, value: bool) -> Self {
52        self.allow_multiple = value;
53        self
54    }
55}