The ByteBuffer
Ruby gem provides a powerful and flexible interface for buffered IO data, wrapping the bytebuffer crate using FFI.
ByteBuffer offers an interface to the compiled rust library for manipulating buffered IO, e.g. reading and writing bits, bytes, integers of various sizes, and floats.
The following packages are required to build and use the gem:
ruby
>= 3.0rustc
cargo
Ensure the following toolchains are installed via rustup:
x86_64-unknown-linux-gnu
A basic example of the ByteBuffer in action can be found below:
require 'bytebuffer'
bb = ByteBuffer.new
bb.write_i32(-128)
puts bb.read_i32 # Output: -128
bb.free