Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send/Sync DialogFutureType #200

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub trait MessageDialogImpl {

// Return type of async dialogs:
#[cfg(not(target_arch = "wasm32"))]
pub type DialogFutureType<T> = Pin<Box<dyn Future<Output = T> + Send>>;
pub type DialogFutureType<T> = Pin<Box<dyn Future<Output = T> + Send + Sync>>;
#[cfg(target_arch = "wasm32")]
pub type DialogFutureType<T> = Pin<Box<dyn Future<Output = T>>>;

Expand Down
13 changes: 6 additions & 7 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::backend::DialogFutureType;
use crate::FileHandle;

use std::path::Path;
Expand Down Expand Up @@ -226,32 +227,30 @@ use crate::backend::AsyncFileSaveDialogImpl;
#[cfg(not(target_arch = "wasm32"))]
use crate::backend::AsyncFolderPickerDialogImpl;

use std::future::Future;

impl AsyncFileDialog {
/// Pick one file
pub fn pick_file(self) -> impl Future<Output = Option<FileHandle>> {
pub fn pick_file(self) -> DialogFutureType<Option<FileHandle>> {
AsyncFilePickerDialogImpl::pick_file_async(self.file_dialog)
}

/// Pick multiple files
pub fn pick_files(self) -> impl Future<Output = Option<Vec<FileHandle>>> {
pub fn pick_files(self) -> DialogFutureType<Option<Vec<FileHandle>>> {
AsyncFilePickerDialogImpl::pick_files_async(self.file_dialog)
}

#[cfg(not(target_arch = "wasm32"))]
/// Pick one folder
///
/// Does not exist in `WASM32`
pub fn pick_folder(self) -> impl Future<Output = Option<FileHandle>> {
pub fn pick_folder(self) -> DialogFutureType<Option<FileHandle>> {
AsyncFolderPickerDialogImpl::pick_folder_async(self.file_dialog)
}

#[cfg(not(target_arch = "wasm32"))]
/// Pick multiple folders
///
/// Does not exist in `WASM32`
pub fn pick_folders(self) -> impl Future<Output = Option<Vec<FileHandle>>> {
pub fn pick_folders(self) -> DialogFutureType<Option<Vec<FileHandle>>> {
AsyncFolderPickerDialogImpl::pick_folders_async(self.file_dialog)
}

Expand All @@ -274,7 +273,7 @@ impl AsyncFileDialog {
/// - No filtering is applied.
/// - `save_file` returns immediately without a dialog prompt.
/// Instead the user is prompted by their browser on where to save the file when [`FileHandle::write`] is used.
pub fn save_file(self) -> impl Future<Output = Option<FileHandle>> {
pub fn save_file(self) -> DialogFutureType<Option<FileHandle>> {
AsyncFileSaveDialogImpl::save_file_async(self.file_dialog)
}
}
Loading