mlua-periphery 0.1.6

A Rust-native implementation of lua-periphery for mlua.
docs.rs failed to build mlua-periphery-0.1.6
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: mlua-periphery-0.1.0

mlua-periphery

A Rust-native implementation of lua-periphery for mlua.

License Arch Lua

From lua-periphery:

lua-periphery is a library for GPIO, LED, PWM, SPI, I2C, MMIO, and Serial peripheral I/O interface access in userspace Linux. It is useful in embedded Linux environments (including Raspberry Pi, BeagleBone, etc. platforms) for interfacing with external peripherals.

Using Python or C? Check out the python-periphery and c-periphery projects.

Installing

Add to your Rust project using one of MLua's features: [lua51, lua52, lua53, lua54, luajit, luajit52].

$ cargo add mlua-periphery --features luajit

Using

use mlua::Lua;

let lua = Lua::new();
mlua_periphery::preload(&lua);
let script = r#"
    local LED = require('periphery.LED')
    local led = LED('led0')
    return led:read(), led.brightness, led.max_brightness
"#;
let (value, brightness, max_brightness): (bool, u32, u32) = lua.load(script).eval()?;

Testing

An integration_tests.rs file exists in each submodule and demonstrates: