remove_all_decoders

This commit is contained in:
Martin Kavík 2024-07-07 14:53:30 +02:00
parent deef698f8d
commit b2055ff22d
8 changed files with 46 additions and 1 deletions

View file

@ -16,6 +16,7 @@ use browser as platform;
type Filename = String;
type JavascriptCode = String;
type AddedDecodersCount = usize;
type RemovedDecodersCount = usize;
type DecoderPath = String;
pub async fn show_window() {
@ -64,3 +65,7 @@ pub async fn unload_signal(signal_ref: wellen::SignalRef) {
pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount {
platform::add_decoders(decoder_paths).await
}
pub async fn remove_all_decoders() -> RemovedDecodersCount {
platform::remove_all_decoders().await
}

View file

@ -128,3 +128,9 @@ pub(super) async fn add_decoders(
eprintln!("Adding decoders is not supported in the browser.");
0
}
pub(super) async fn remove_all_decoders() -> super::RemovedDecodersCount {
// @TODO error message for user
eprintln!("Removing decoders is not supported in the browser.");
0
}

View file

@ -63,6 +63,11 @@ pub(super) async fn add_decoders(
.unwrap_throw()
}
pub(super) async fn remove_all_decoders() -> super::RemovedDecodersCount {
serde_wasm_bindgen::from_value(tauri_glue::remove_all_decoders().await.unwrap_throw())
.unwrap_throw()
}
mod tauri_glue {
use zoon::*;
@ -98,5 +103,8 @@ mod tauri_glue {
pub async fn add_decoders(
decoder_paths: Vec<super::super::DecoderPath>,
) -> Result<JsValue, JsValue>;
#[wasm_bindgen(catch)]
pub async fn remove_all_decoders() -> Result<JsValue, JsValue>;
}
}

View file

@ -4,6 +4,7 @@ use zoon::*;
type FullVarName = String;
type AddedDecodersCount = usize;
type RemovedDecodersCount = usize;
type DecoderPath = String;
#[wasm_bindgen(module = "/typescript/bundles/strict_eval.js")]
@ -72,4 +73,9 @@ impl FW {
pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount {
platform::add_decoders(decoder_paths).await
}
/// JS: `FW.remove_all_decoders()` -> `5`
pub async fn remove_all_decoders() -> RemovedDecodersCount {
platform::remove_all_decoders().await
}
}