#roblox #binary #dom #rbxm #rbxl

rbx_binary

Implementation of Roblox’s binary model (rbxm) and place (rbxl) file formats

17 releases

new 0.6.6 Jun 29, 2022
0.6.4 Oct 11, 2021
0.6.2 Jul 19, 2021
0.6.0-alpha.3 Mar 9, 2021
0.4.0 Mar 1, 2019

#14 in Games

Download history 124/week @ 2022-03-11 102/week @ 2022-03-18 49/week @ 2022-03-25 33/week @ 2022-04-01 72/week @ 2022-04-08 95/week @ 2022-04-15 59/week @ 2022-04-22 283/week @ 2022-04-29 230/week @ 2022-05-06 307/week @ 2022-05-13 216/week @ 2022-05-20 198/week @ 2022-05-27 404/week @ 2022-06-03 251/week @ 2022-06-10 172/week @ 2022-06-17 204/week @ 2022-06-24

1,102 downloads per month
Used in 3 crates

MIT license

290KB
4.5K SLoC

rbx_binary

rbx_binary on crates.io rbx_binary docs

More details about this crate are available on the rbx-dom GitHub.

Implementation of Roblox's binary model formats, rbxm and rbxl, for the rbx-dom ecosystem.

Coverage

rbx_binary aims to support all property types from rbx_dom_weak, but it currently lags behind rbx_xml due to implementation complexity.


lib.rs:

Implementation of Roblox's binary model (rbxm) and place (rbxl) file formats.

Examples

Read a model file

To read a model or place file using rbx_binary's default settings, use [from_reader]. The [Deserializer] API exposes additional configuration options.

use std::fs::File;
use std::io::BufReader;

// Using buffered I/O is recommended with rbx_binary
let input = BufReader::new(File::open("MyModel.rbxm")?);

let dom = rbx_binary::from_reader(input)?;

// rbx_binary always returns a DOM with a DataModel at the top level.
// To get to the instances from our file, we need to go one level deeper.

println!("Root instances in file:");
for &referent in dom.root().children() {
let instance = dom.get_by_ref(referent).unwrap();
println!("- {}", instance.name);
}

# Ok::<(), Box<dyn std::error::Error>>(())

Write a model file

To write a model or place file using rbx_binary's default settings, use [to_writer]. The [Serializer] API exposes additional configuration options.

use std::fs::File;
use std::io::BufWriter;

use rbx_dom_weak::{InstanceBuilder, WeakDom};

let dom = WeakDom::new(InstanceBuilder::new("Folder"));

// Using buffered I/O is recommended with rbx_binary
let output = BufWriter::new(File::create("PlainFolder.rbxm")?);
rbx_binary::to_writer(output, &dom, &[dom.root_ref()])?;

# Ok::<(), Box<dyn std::error::Error>>(())

Dependencies

~6.5MB
~100K SLoC