pub struct RbxTree { /* private fields */ }Expand description
Represents a tree containing rooted instances.
Rooted instances are described by RbxInstance and have an ID, children, and a parent.
Implementations§
Source§impl RbxTree
impl RbxTree
Sourcepub fn new(root_properties: RbxInstanceProperties) -> RbxTree
pub fn new(root_properties: RbxInstanceProperties) -> RbxTree
Construct a new RbxTree with its root instance constructed using the
given properties.
Sourcepub fn get_root_id(&self) -> RbxId
pub fn get_root_id(&self) -> RbxId
Returns the ID of the root instance in the tree, which can be used
alongside get_instance and friends.
Sourcepub fn iter_all_ids(&self) -> impl Iterator<Item = RbxId> + '_
pub fn iter_all_ids(&self) -> impl Iterator<Item = RbxId> + '_
Returns an iterator over all IDs in the tree.
Sourcepub fn get_instance(&self, id: RbxId) -> Option<&RbxInstance>
pub fn get_instance(&self, id: RbxId) -> Option<&RbxInstance>
Returns the instance with the given ID if it’s contained in this tree.
Sourcepub fn get_instance_mut(&mut self, id: RbxId) -> Option<&mut RbxInstance>
pub fn get_instance_mut(&mut self, id: RbxId) -> Option<&mut RbxInstance>
Returns mutable access to the instance with the given ID if it’s contained in this tree.
Sourcepub fn insert_instance(
&mut self,
properties: RbxInstanceProperties,
parent_id: RbxId,
) -> RbxId
pub fn insert_instance( &mut self, properties: RbxInstanceProperties, parent_id: RbxId, ) -> RbxId
Inserts a new instance with the given properties into the tree, putting it under the instance with the given ID.
§Panics
Panics if the given ID does not refer to an instance in this tree.
Sourcepub fn remove_instance(&mut self, root_id: RbxId) -> Option<RbxTree>
pub fn remove_instance(&mut self, root_id: RbxId) -> Option<RbxTree>
Given an ID, remove the instance from the tree with that ID, along with all of its descendants.
Sourcepub fn descendants(&self, id: RbxId) -> Descendants<'_> ⓘ
pub fn descendants(&self, id: RbxId) -> Descendants<'_> ⓘ
Returns an iterator over all of the descendants of the given instance by ID.