Crates.io | rsciter |
lib.rs | rsciter |
version | 0.0.11 |
source | src |
created_at | 2023-07-09 11:42:52.378165 |
updated_at | 2024-09-19 15:43:52.793119 |
description | Unofficial Rust bindings for Sciter |
homepage | |
repository | https://github.com/vsrs/rsciter |
max_upload_size | |
id | 912011 |
size | 299,683 |
This is unofficial Rust bindings for Sciter
This is a work in progress library and is not yet ready for production use.
#[rsciter::xmod] // mark the module, that's it!
mod NativeModule {
pub fn append_log(id: u64, message: &str) { ... }
pub fn user_name() -> String { ... }
}
JS side:
const sum = Window.this.xcall("sum", 12, 12);
For details, see this samples:
You can export entire backend module with a single #[rsciter::asset_ns]
macro:
#[rsciter::asset_ns]
mod Db {
// exported Db.open function
pub fn open(path: &str, flags: u64) -> Object {...}
// exported struct with fields
pub struct Object {
path: String,
flags: u64,
}
// additionally export update method
impl Object {
pub fn update(&self, value: &str) -> UpdateRes {...}
}
// exported struct with `message` method
struct UpdateRes(String);
impl UpdateRes {
pub fn message(&self) -> &str {
&self.0
}
}
}
JS side:
const obj = Db.open("test.db", 4);
console.log(`open result: "${obj}, ${obj.path}, ${obj.flags}"`);
// open result: "[asset Object], test.db, 4"
const updateRes = obj.update("new data");
console.log(updateRes, updateRes.message);
// [asset UpdateRes] function () {
// [native code]
// }
console.log(`Update result: "${updateRes.message()}"`);
// Update result: "Updating: `new data` for `test.db` with `4`"
SOM samples: