add sdk crate
This commit is contained in:
parent
0a21933795
commit
dff72850ce
5 changed files with 35 additions and 15 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -2686,6 +2686,7 @@ dependencies = [
|
|||
name = "journal"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"panorama-app-sdk",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
|
@ -3469,6 +3470,13 @@ dependencies = [
|
|||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "panorama-app-sdk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "panorama-core"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -8,3 +8,4 @@ crate-type = ["cdylib", "rlib"]
|
|||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2.92"
|
||||
panorama-app-sdk = { path = "../../crates/panorama-app-sdk" }
|
||||
|
|
|
@ -2,22 +2,8 @@ use std::ffi::CString;
|
|||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
mod sys {
|
||||
use std::ffi::c_char;
|
||||
|
||||
extern "C" {
|
||||
pub fn register_endpoint(url: *const c_char);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_endpoint(url: impl AsRef<str>) {
|
||||
let url = CString::new(url.as_ref()).unwrap();
|
||||
let result = unsafe { sys::register_endpoint(url.into_raw()) };
|
||||
println!("Result: {:?}", result);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn install() -> i32 {
|
||||
register_endpoint("/hello");
|
||||
panorama_app_sdk::register_endpoint("/hello");
|
||||
123
|
||||
}
|
||||
|
|
10
crates/panorama-app-sdk/Cargo.toml
Normal file
10
crates/panorama-app-sdk/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "panorama-app-sdk"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2.92"
|
15
crates/panorama-app-sdk/src/lib.rs
Normal file
15
crates/panorama-app-sdk/src/lib.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
use std::ffi::CString;
|
||||
|
||||
pub mod sys {
|
||||
use std::ffi::c_char;
|
||||
|
||||
extern "C" {
|
||||
pub fn register_endpoint(url: *const c_char);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register_endpoint(url: impl AsRef<str>) {
|
||||
let url = CString::new(url.as_ref()).unwrap();
|
||||
let result = unsafe { sys::register_endpoint(url.into_raw()) };
|
||||
println!("Result: {:?}", result);
|
||||
}
|
Loading…
Reference in a new issue