(&mut self, init: InitCb, result_cb: ResultCb)
| 22 | |
| 23 | impl FileDialogState { |
| 24 | pub fn queue<InitCb, ResultCb>(&mut self, init: InitCb, result_cb: ResultCb) |
| 25 | where |
| 26 | InitCb: FnOnce() -> Pin<Box<dyn Future<Output = Option<FileHandle>> + Send>>, |
| 27 | ResultCb: FnOnce(Utf8PlatformPathBuf) -> FileDialogResult + Send + 'static, |
| 28 | { |
| 29 | if self.thread.is_some() { |
| 30 | return; |
| 31 | } |
| 32 | let future = init(); |
| 33 | self.thread = Some(std::thread::spawn(move || { |
| 34 | if let Some(handle) = future.block_on() { |
| 35 | let path = PathBuf::from(handle); |
| 36 | check_path_buf(path).map(result_cb).unwrap_or(FileDialogResult::None) |
| 37 | } else { |
| 38 | FileDialogResult::None |
| 39 | } |
| 40 | })); |
| 41 | } |
| 42 | |
| 43 | pub fn poll(&mut self) -> FileDialogResult { |
| 44 | if let Some(thread) = &mut self.thread { |
no test coverage detected