GitXplorerGitXplorer
v

rsciter

public
6 stars
2 forks
1 issues

Commits

List of commits on branch master.
Unverified
00b8b0b211b0b7cdba5d5db27194c0854a751e2b

Release 0.0.11

vvsrs committed 4 months ago
Unverified
71bd416670bdd6e50ec6b7462b5781d264aaefb9

Update readme

vvsrs committed 4 months ago
Unverified
21e5d94b3a8f7536a36ffdf3ca6d4053b2b371d0

Window assets only in custom event handlers

vvsrs committed 4 months ago
Unverified
0521fcbd3c5043504893fb54f1f7848ab5ab075f

WIP: IAsset refactoring

vvsrs committed 4 months ago
Unverified
168f8b8f2d2309efa795ab6b1e7ef528681c5c0b

Rename to with_xfunction & with_xmodule

vvsrs committed 4 months ago
Unverified
0e180c8c33b023320c32f26e8a152cf6ce6e3067

use cleanup

vvsrs committed 4 months ago

README

The README file for this repository.

Description

Work in Progress License

This is unofficial Rust bindings for Sciter

Disclaimer

This is a work in progress library and is not yet ready for production use.

Differencies from rust-sciter

  • Never panics
  • Uses bindgen instead of hand-written code.
  • Utilizes Sciter's own functions for windows/application management.
  • The primary goal is not to provide a complete Sciter API, but to simplify the interaction between the backend (in Rust) and the frontend (Sciter.JS UI).

Exporting xfunctions (e.g. functions available via window.xcall)

#[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:

Sciter Object Model support

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: