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"
|
name = "journal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"panorama-app-sdk",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3469,6 +3470,13 @@ dependencies = [
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "panorama-app-sdk"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "panorama-core"
|
name = "panorama-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
@ -8,3 +8,4 @@ crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasm-bindgen = "0.2.92"
|
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;
|
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]
|
#[wasm_bindgen]
|
||||||
pub fn install() -> i32 {
|
pub fn install() -> i32 {
|
||||||
register_endpoint("/hello");
|
panorama_app_sdk::register_endpoint("/hello");
|
||||||
123
|
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