0.6.7 |
|
---|
#62 in #roblox
330KB
5K
SLoC
rbx_binary
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);
}
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()])?;
Dependencies
~5.5MB
~115K SLoC