v0.1.4-pre.004
This commit is contained in:
33
crates/ksp-app-config-desk/src/tauri.rs
Normal file
33
crates/ksp-app-config-desk/src/tauri.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
// file: crates/ksp-app-config-desk/src/tauri.rs
|
||||
// version: 1
|
||||
|
||||
//! Tauri runtime assembly for the KSP configuration desktop application.
|
||||
|
||||
use tauri::Manager; // rust-rules: trait-import
|
||||
|
||||
/// Runs the configuration desktop application.
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run(_arguments: &[std::ffi::OsString]) -> ksp_core_lib::Result<()> {
|
||||
let mut builder = tauri::Builder::default();
|
||||
builder = configure_setup(builder);
|
||||
let run_result = builder.run(tauri::generate_context!());
|
||||
return match run_result {
|
||||
std::result::Result::Ok(()) => std::result::Result::Ok(()),
|
||||
std::result::Result::Err(error) => std::result::Result::Err(
|
||||
ksp_core_lib::Error::new(crate::ERROR_CODE_TAURI_RUNTIME_FAILED, "Cannot run KSP Config Desk Tauri runtime")
|
||||
.with_context("tauri_error", error.to_string()),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
fn configure_setup(builder: tauri::Builder<tauri::Wry>) -> tauri::Builder<tauri::Wry> {
|
||||
return builder.setup(|app| {
|
||||
if app.get_webview_window("splash").is_none() {
|
||||
return std::result::Result::Err(std::boxed::Box::new(std::io::Error::new(std::io::ErrorKind::NotFound, "splash window is missing")));
|
||||
}
|
||||
if app.get_webview_window("main").is_none() {
|
||||
return std::result::Result::Err(std::boxed::Box::new(std::io::Error::new(std::io::ErrorKind::NotFound, "main window is missing")));
|
||||
}
|
||||
return std::result::Result::Ok(());
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user