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

44 lines
824 B
Rust

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