MoonBit Foreign Function Interface.
https://github.com/justjavac/moonbit-ffi.git
A lightweight utility library for converting between Cβstyle null-terminated
byte strings (Bytes) and MoonBit String values.
[]()
Bytes to a MoonBit String (drops\x00 terminator).
String to null-terminated Bytes.Add justjavac/ffi to your dependencies:
moon update
moon add justjavac/ffi
// Convert Bytes β String
let data = b"Hello, world!\x00"
let s = @ffi.from_cstr(data)
assert_eq!(s, "Hello, world!")
// Convert String β Bytes
let cstr = @ffi.to_cstr("Hello, world!")
assert_eq!(cstr, data)
Build the library and run tests (including docs):
moon build
moon test --doc
This project is licensed under the MIT License.\ Β© justjavac