Crate rbx_binary[][src]

Expand description

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()])?;

Structs

Represents an error that occurred during deserialization.

A configurable deserializer for Roblox binary models and places.

Represents an error that occurred during serialization.

A configurable serializer for Roblox binary models and places.

Functions

Deserialize a Roblox binary model or place from a stream.

Serializes a subset of the given DOM to a binary format model or place, writing to something that implements the std::io::Write trait.