Crates.io | yaslapi |
lib.rs | yaslapi |
version | 0.1.0 |
source | src |
created_at | 2023-09-08 05:10:30.288169 |
updated_at | 2023-09-08 05:10:30.288169 |
description | A library that provides safe bindings to the Yet Another Scripting Language (YASL) API. |
homepage | |
repository | |
max_upload_size | |
id | 966793 |
size | 59,277 |
yaslapi is a Rust library that provides safe idiomatic wrapper for the Yet Another Scripting Language (YASL) API.
First, you must have CMake and a C compiler installed so that YASL can be compiled locally.
To install yaslapi, add the following to your Cargo.toml
file:
[dependencies]
yaslapi = "0.1.0"
Then run cargo build to build your project.
Here’s an example of how to use yaslapi in your Rust code:
extern crate yaslapi;
use yaslapi::{Error, State};
fn main() {
// Initialize test script
let mut state = State::new("test.yasl");
// Init new variable `answer` with the top of the stack (in this case, the `42`)
state.push_int(42);
state.init_global("answer");
// Add Rust implemented function `rust_print` to globals
state.push_cfunction(rust_print, 0);
state.init_global("rust_print");
// Execute `test.yasl`, now that we're done setting everything up
assert_eq!(state.execute(), Error::Success);
}
yaslapi is licensed under the MIT License.