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

source

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.

source

pub fn empty() -> Self

Create a new InstanceBuilder with all values set to empty.

source

pub fn referent(&self) -> Ref

Return the referent of the instance that the InstanceBuilder refers to.

source

pub fn with_name<S: Into<String>>(self, name: S) -> Self

Change the name of the InstanceBuilder.

source

pub fn set_name<S: Into<String>>(&mut self, name: S)

Change the name of the InstanceBuilder.

source

pub fn with_class<S: Into<String>>(self, class: S) -> Self

Change the class of the InstanceBuilder.

source

pub fn set_class<S: Into<String>>(&mut self, class: S)

Change the class of the InstanceBuilder.

source

pub fn with_property<K: Into<String>, V: Into<Variant>>( self, key: K, value: V ) -> Self

Add a new property to the InstanceBuilder.

source

pub fn add_property<K: Into<String>, V: Into<Variant>>( &mut self, key: K, value: V )

Add a new property to the InstanceBuilder.

source

pub fn has_property<K: Into<String>>(&self, key: K) -> bool

Check if the InstanceBuilder already has a property with the given key.

source

pub fn with_properties<K, V, I>(self, props: I) -> Self
where K: Into<String>, V: Into<Variant>, I: IntoIterator<Item = (K, V)>,

Add multiple properties to the InstanceBuilder at once.

source

pub fn add_properties<K, V, I>(&mut self, props: I)
where K: Into<String>, V: Into<Variant>, I: IntoIterator<Item = (K, V)>,

Add multiple properties to the InstanceBuilder at once.

source

pub fn with_child(self, child: InstanceBuilder) -> Self

Add a new child to the InstanceBuilder.

source

pub fn add_child(&mut self, child: InstanceBuilder)

Add a new child to the InstanceBuilder.

source

pub fn with_children<I>(self, children: I) -> Self
where I: IntoIterator<Item = InstanceBuilder>,

Add multiple children to the InstanceBuilder at once.

Order of the children will be preserved.

source

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.

Trait Implementations§

source§

impl Debug for InstanceBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V