Mercurial > core / rust/ui/alik/examples/installer.rs
changeset 698: |
96958d3eb5b0 |
parent: |
bea77d97c6b2
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 //! installer.rs --- Alik Installer Example 6 use std::future::Future; 8 #[cfg(not(target_arch = "wasm32"))] 9 fn execute<F: Future<Output = ()> + Send + 'static>(f: F) { 10 // this is stupid... use any executor of your choice instead 11 std::thread::spawn(move || futures::executor::block_on(f)); 13 #[cfg(target_arch = "wasm32")] 14 fn execute<F: Future<Output = ()> + 'static>(f: F) { 15 wasm_bindgen_futures::spawn_local(f); 18 fn main() -> Result<(), Box<dyn std::error::Error>> { 20 let res = rfd::MessageDialog::new() 22 .set_description("Description!") 23 .set_buttons(rfd::MessageButtons::OkCancel) 27 let task = rfd::AsyncFileDialog::new().pick_file(); 29 // Await somewhere else 31 let file = task.await; 33 if let Some(file) = file { 34 // If you are on native platform you can just get the path 35 #[cfg(not(target_arch = "wasm32"))] 36 println!("{:?}", file.path()); 37 // on wasm just file.read().await; 41 "alik_installer_example", 42 eframe::NativeOptions::default(), 43 Box::new(|cc| Box::new(alik_ui::AlikApp::new(cc))),