Struct rbx_dom_weak::InstanceBuilder
source · pub struct InstanceBuilder { /* private fields */ }
Expand description
Represents an instance that can be turned into a new
WeakDom
, or inserted into an existing one.
Examples
Instances have the given ClassName and Name and no properties by default.
use rbx_dom_weak::{InstanceBuilder, WeakDom};
let data_model = InstanceBuilder::new("DataModel");
let dom = WeakDom::new(data_model);
Properties and children can be added to the builder.
use rbx_dom_weak::{InstanceBuilder, WeakDom};
use rbx_dom_weak::types::Color3;
let data_model = InstanceBuilder::new("DataModel")
.with_child(InstanceBuilder::new("Workspace")
.with_property("FilteringEnabled", true))
.with_child(InstanceBuilder::new("Lighting")
.with_property("Ambient", Color3::new(1.0, 0.0, 0.0)));
let dom = WeakDom::new(data_model);
Implementations§
source§impl InstanceBuilder
impl InstanceBuilder
sourcepub fn new<S: Into<String>>(class: S) -> Self
pub fn new<S: Into<String>>(class: S) -> Self
Create a new InstanceBuilder
with the given ClassName. This is also
used as the instance’s Name, unless overwritten later.
sourcepub fn referent(&self) -> Ref
pub fn referent(&self) -> Ref
Return the referent of the instance that the InstanceBuilder
refers to.
sourcepub fn with_name<S: Into<String>>(self, name: S) -> Self
pub fn with_name<S: Into<String>>(self, name: S) -> Self
Change the name of the InstanceBuilder
.
sourcepub fn with_class<S: Into<String>>(self, class: S) -> Self
pub fn with_class<S: Into<String>>(self, class: S) -> Self
Change the class of the InstanceBuilder
.
sourcepub fn set_class<S: Into<String>>(&mut self, class: S)
pub fn set_class<S: Into<String>>(&mut self, class: S)
Change the class of the InstanceBuilder
.
sourcepub fn with_property<K: Into<String>, V: Into<Variant>>(
self,
key: K,
value: V
) -> Self
pub fn with_property<K: Into<String>, V: Into<Variant>>( self, key: K, value: V ) -> Self
Add a new property to the InstanceBuilder
.
sourcepub fn add_property<K: Into<String>, V: Into<Variant>>(
&mut self,
key: K,
value: V
)
pub fn add_property<K: Into<String>, V: Into<Variant>>( &mut self, key: K, value: V )
Add a new property to the InstanceBuilder
.
sourcepub fn has_property<K: Into<String>>(&self, key: K) -> bool
pub fn has_property<K: Into<String>>(&self, key: K) -> bool
Check if the InstanceBuilder
already has a property with the given key.
sourcepub fn with_properties<K, V, I>(self, props: I) -> Self
pub fn with_properties<K, V, I>(self, props: I) -> Self
Add multiple properties to the InstanceBuilder
at once.
sourcepub fn add_properties<K, V, I>(&mut self, props: I)
pub fn add_properties<K, V, I>(&mut self, props: I)
Add multiple properties to the InstanceBuilder
at once.
sourcepub fn with_child(self, child: InstanceBuilder) -> Self
pub fn with_child(self, child: InstanceBuilder) -> Self
Add a new child to the InstanceBuilder
.
sourcepub fn add_child(&mut self, child: InstanceBuilder)
pub fn add_child(&mut self, child: InstanceBuilder)
Add a new child to the InstanceBuilder
.
sourcepub fn with_children<I>(self, children: I) -> Selfwhere
I: IntoIterator<Item = InstanceBuilder>,
pub fn with_children<I>(self, children: I) -> Selfwhere
I: IntoIterator<Item = InstanceBuilder>,
Add multiple children to the InstanceBuilder
at once.
Order of the children will be preserved.
sourcepub fn add_children<I>(&mut self, children: I)where
I: IntoIterator<Item = InstanceBuilder>,
pub fn add_children<I>(&mut self, children: I)where
I: IntoIterator<Item = InstanceBuilder>,
Add multiple children to the InstanceBuilder
at once.
Order of the children will be preserved.