ferroui_base/platform/storage/open_file_picker_result.rs
1use super::{FilePickerFileType, IStorageFile};
2use std::rc::Rc;
3
4/// Extended result of the
5/// [`IStorageProvider::open_file_picker_with_result_async`](super::IStorageProvider::open_file_picker_with_result_async)
6/// operation.
7#[derive(Clone, Default)]
8pub struct OpenFilePickerResult {
9 /// The list of files picked by the user, empty if the user canceled
10 /// the dialog.
11 pub files: Vec<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 files and the same file type.
22impl PartialEq for OpenFilePickerResult {
23 fn eq(&self, other: &Self) -> bool {
24 self.files.len() == other.files.len()
25 && self.files.iter().zip(&other.files).all(|(a, b)| Rc::ptr_eq(a, b))
26 && self.selected_file_type == other.selected_file_type
27 }
28}