add sdk crate

This commit is contained in:
Michael Zhang 2024-06-21 18:04:53 -05:00
parent 0a21933795
commit dff72850ce
5 changed files with 35 additions and 15 deletions

8
Cargo.lock generated
View file

@ -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"

View file

@ -8,3 +8,4 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
wasm-bindgen = "0.2.92"
panorama-app-sdk = { path = "../../crates/panorama-app-sdk" }

View file

@ -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
}

View 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"

View 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);
}