monorepo/kifu/ffi/wasm/src/lib.rs

44 lines
824 B
Rust
Raw Normal View History

use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
pub fn log(s: &str);
}
2023-04-21 13:25:21 +00:00
/*
#[wasm_bindgen]
2023-04-21 13:25:21 +00:00
pub struct CoreRequest(kifu_core::Request);
#[wasm_bindgen]
2023-04-21 13:25:21 +00:00
impl CoreRequest {
#[wasm_bindgen(constructor)]
pub fn new(request: kifu_core::Request) -> Self {
Self(request)
}
}
*/
2023-04-21 13:25:21 +00:00
/* Somehow uncommenting this code actually causes the module to not load. Maybe a name conflict?
* Don't know.
*/
#[wasm_bindgen]
2023-04-21 13:25:21 +00:00
pub struct CoreResponse(kifu_core::Response);
#[wasm_bindgen]
2023-04-21 13:25:21 +00:00
#[derive(Debug)]
pub struct CoreApp;
#[wasm_bindgen]
2023-04-21 13:25:21 +00:00
impl CoreApp {
#[wasm_bindgen(constructor)]
pub fn new() -> Self {
Self
}
#[wasm_bindgen]
pub async fn dispatch(&self, param: &JsValue) {
log(&format!("disptach! {:?}", param));
}
}