pub mod open;
pub mod save;
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SaveTarget {
Export,
SweepSpec,
SweepResults(u64),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SaveResult {
#[cfg_attr(
target_arch = "wasm32",
expect(dead_code, reason = "a browser saves through its downloads")
)]
Saved(String),
#[cfg_attr(not(target_arch = "wasm32"), expect(dead_code, reason = "only a browser downloads"))]
Downloaded(String),
#[cfg_attr(not(target_arch = "wasm32"), expect(dead_code, reason = "only a browser downloads"))]
DownloadsStarted,
Failed(String),
#[cfg_attr(
target_arch = "wasm32",
expect(dead_code, reason = "a browser download has no dialog")
)]
Canceled,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SaveOutcome {
pub target: SaveTarget,
pub result: SaveResult,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OpenTarget {
SweepSpec,
DesignTable,
OutputFolder,
Results,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DialogFile {
pub name: String,
pub bytes: Vec<u8>,
pub path: Option<PathBuf>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OpenResult {
Files(Vec<DialogFile>),
#[cfg_attr(target_arch = "wasm32", expect(dead_code, reason = "a browser picks no folder"))]
Folder(PathBuf),
Failed(String),
Canceled,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OpenOutcome {
pub target: OpenTarget,
pub result: OpenResult,
}
#[cfg(not(target_arch = "wasm32"))]
fn spawn(task: impl Future<Output = ()> + Send + 'static) {
std::thread::spawn(move || pollster::block_on(task));
}
#[cfg(target_arch = "wasm32")]
fn spawn(task: impl Future<Output = ()> + 'static) {
wasm_bindgen_futures::spawn_local(task);
}