Skip to main content

ferroui_base/platform/storage/
save_file_picker_result.rs

1use super::{FilePickerFileType, IStorageFile};
2use std::rc::Rc;
3
4/// Extended result of the
5/// [`IStorageProvider::save_file_picker_with_result_async`](super::IStorageProvider::save_file_picker_with_result_async)
6/// operation.
7#[derive(Clone, Default)]
8pub struct SaveFilePickerResult {
9    /// The file picked by the user, or `None` if the user canceled the
10    /// dialog.
11    pub file: Option<Rc<dyn IStorageFile>>,
12
13    /// The file type selected by the user in the dialog.
14    ///
15    /// This value is `None` if the user canceled the dialog. It can also
16    /// be `None` if the platform does not provide this information.
17    pub selected_file_type: Option<Rc<FilePickerFileType>>,
18}
19
20/// Value equality over the members, each of which is a reference: two
21/// results are equal when they hold the same file and the same file type.
22impl PartialEq for SaveFilePickerResult {
23    fn eq(&self, other: &Self) -> bool {
24        let same_file = match (&self.file, &other.file) {
25            (Some(a), Some(b)) => Rc::ptr_eq(a, b),
26            (None, None) => true,
27            _ => false,
28        };
29        same_file && self.selected_file_type == other.selected_file_type
30    }
31}