#roblox #binary #dom #rbxm #rbxl

rbx_binary

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

15 releases

0.6.4 Oct 11, 2021
0.6.2 Jul 19, 2021
0.6.0-alpha.3 Mar 9, 2021
0.5.0 Dec 18, 2019
0.4.0 Mar 1, 2019

#10 in Games

Download history 115/week @ 2021-07-04 69/week @ 2021-07-11 113/week @ 2021-07-18 134/week @ 2021-07-25 128/week @ 2021-08-01 136/week @ 2021-08-08 113/week @ 2021-08-15 219/week @ 2021-08-22 123/week @ 2021-08-29 71/week @ 2021-09-05 87/week @ 2021-09-12 112/week @ 2021-09-19 53/week @ 2021-09-26 34/week @ 2021-10-03 119/week @ 2021-10-10 77/week @ 2021-10-17

456 downloads per month
Used in 3 crates

MIT license

275KB
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

~5MB
~116K SLoC