yaslapi

Crates.ioyaslapi
lib.rsyaslapi
version0.1.0
sourcesrc
created_at2023-09-08 05:10:30.288169
updated_at2023-09-08 05:10:30.288169
descriptionA library that provides safe bindings to the Yet Another Scripting Language (YASL) API.
homepage
repository
max_upload_size
id966793
size59,277
Ryan Andersen (ryco117)

documentation

README

yaslapi

yaslapi is a Rust library that provides safe idiomatic wrapper for the Yet Another Scripting Language (YASL) API.

Installation

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.

Usage

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

License

yaslapi is licensed under the MIT License.

Commit count: 0

cargo fmt