[][src]Crate rbx_dom_weak

rbx_dom_weak is a common representation of the Roblox DOM for Rust. It's designed to play nicely with the borrow checker and allows accessing instances by ID in constant time.

Constructing a new tree of instances is accomplished by first creating an RbxInstanceProperties object that describes the root instance of the tree, and then wrapping it with an RbxTree:

use std::collections::HashMap;
use rbx_dom_weak::{RbxInstanceProperties, RbxTree};

let props = RbxInstanceProperties {
    name: "My Cool Game".to_owned(),
    class_name: "DataModel".to_owned(),
    properties: HashMap::new(),
};

let mut tree = RbxTree::new(props);
println!("ID of instance we just inserted is {}", tree.get_root_id());

Note that the maplit crate is incredibly useful for defining properties inline.

Once we have a tree, we can use RbxTree::insert_instance and RbxTree::get_instance to add instances to the tree and retrieve them.

use rbx_dom_weak::RbxValue;
use maplit::hashmap;
let http_service = RbxInstanceProperties {
    name: "HttpService".to_owned(),
    class_name: "HttpService".to_owned(),
    properties: hashmap! {
        "HttpEnabled".to_owned() => RbxValue::Bool {
            value: true,
        },
    },
};

let datamodel_id = tree.get_root_id();
let http_service_id = tree.insert_instance(http_service, datamodel_id);

println!("HttpService has ID {}", http_service_id);

To change properties on an instance that's already present in the tree, use RbxTree::get_instance_mut. Note that it isn't possible to add or remove children through this method, use RbxTree::insert_instance instead.

Structs

ColorSequence
ColorSequenceKeypoint
Descendants

An iterator over all descendants of an instance in an RbxTree. Returned by RbxTree::descendants.

NumberSequence
NumberSequenceKeypoint
PhysicalProperties

Represents possible custom physical properties on a BasePart.

Ray
RbxId

A unique ID that represents an instance within an RbxTree.

RbxInstance

Represents an instance that is rooted in an RbxTree. These are always returned from an existing RbxTree with a method like RbxTree::get_instance.

RbxInstanceProperties

The properties associated with a Roblox Instance that might not exist yet.

RbxTree

Represents a tree containing Roblox instances.

Rect
SharedString

A shared buffer of data that is automatically deduplicated so that only one copy of a given buffer is in memory at a time.

Enums

AmbiguousRbxValue

Represents a value that doesn't have explicit type information attached to it. Given more reflection information, it should be possible to recover the exact type of this value.

BrickColor

BrickColor values were the old, palette-based system of defining colors in Roblox. As of the time of writing, they're still used for some old systems like SpawnLocation and Team objects.

RbxValue

Represents a value that can be assigned to the properties of an instance.

RbxValueConversion

Contains the result of trying to convert an RbxValue to another type using RbxValue::try_convert_ref.

RbxValueType

An enum that can hold any of the types that RbxValue can.

UnresolvedRbxValue

Represents a value that was deserialized that might not have full type information attached.