23 stable releases

2.9.0 Aug 22, 2024
2.8.0 Jul 23, 2024
2.7.0 Jan 16, 2024
2.6.0 Oct 3, 2023
0.3.1 Feb 26, 2019

#24 in Games

Download history 435/week @ 2024-07-18 265/week @ 2024-07-25 199/week @ 2024-08-01 298/week @ 2024-08-08 242/week @ 2024-08-15 513/week @ 2024-08-22 259/week @ 2024-08-29 134/week @ 2024-09-05 201/week @ 2024-09-12 316/week @ 2024-09-19 249/week @ 2024-09-26 190/week @ 2024-10-03 234/week @ 2024-10-10 225/week @ 2024-10-17 197/week @ 2024-10-24 176/week @ 2024-10-31

863 downloads per month
Used in 14 crates (10 directly)

MIT license

190KB
4.5K SLoC

rbx_dom_weak

rbx_dom_weak on crates.io rbx_dom_weak docs

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

Weakly-typed implementation of Roblox's DOM, used for representing instances in external tools.

Coverage

Because rbx_dom_weak is weakly-typed, it doesn't need to be updated when new instances are added to Roblox. It does, however, have to be updated when new datatypes like Vector3int16 are added.


lib.rs:

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 InstanceBuilder object that describes a tree of instances and then wrapping it with an WeakDom:

use rbx_dom_weak::{InstanceBuilder, WeakDom};

let dm = InstanceBuilder::new("DataModel");

let mut dom = WeakDom::new(dm);

println!("ID of DOM root is {:?}", dom.root_ref());

Once we have a tree, we can use WeakDom::insert and WeakDom::get_by_ref to add instances to the tree and retrieve them.

use rbx_dom_weak::{InstanceBuilder, WeakDom};

let mut dom = WeakDom::new(InstanceBuilder::new("DataModel"));

// We can define properties using any type that can be converted to an
// rbx_dom_weak::types::Variant.
let http_service = InstanceBuilder::new("HttpService")
    .with_property("HttpEnabled", true);

let http_service_id = dom.insert(dom.root_ref(), http_service);

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

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

Dependencies

~2.3–3.5MB
~80K SLoC