Struct Dom

Source
pub struct Dom { /* private fields */ }
Expand description

The DOM that contains the tree of active widgets.

Implementations§

Source§

impl Dom

Source

pub fn new() -> Self

Create a new, empty DOM.

Source

pub fn start(&self)

Start the build phase for the DOM and bind it to the current thread.

Source

pub fn finish(&self, input: &InputState)

End the DOM’s build phase.

Source

pub fn len(&self) -> usize

Tells how many nodes are currently in the DOM.

Source

pub fn is_empty(&self) -> bool

Tells whether the DOM is empty.

Source

pub fn root(&self) -> WidgetId

Gives the root widget in the DOM. This widget will always exist.

Source

pub fn request_focus(&self, id: WidgetId)

Request focus for the given widget id

Source

pub fn current(&self) -> WidgetId

If the DOM is being built, tells which widget is currently being built.

This method only gives valid results when called from inside a Widget lifecycle method.

Source

pub fn get_current(&self) -> Ref<'_, DomNode>

Returns a reference to the current DOM node. See Dom::current.

Source

pub fn get(&self, id: WidgetId) -> Option<Ref<'_, DomNode>>

Get the node with the given widget ID.

Source

pub fn get_mut(&self, id: WidgetId) -> Option<RefMut<'_, DomNode>>

Get a mutable reference to the node with the given widget ID.

Source

pub fn get_global_or_init<T, F>(&self, init: F) -> T
where T: 'static + Clone, F: FnOnce() -> T,

Get a piece of DOM-global state or initialize it with the given function.

This is intended for any state that is global. It’s not a perfect fit for scoped state like themes.

Source

pub fn do_widget<T: Widget>(&self, props: T::Props<'_>) -> Response<T::Response>

Convenience method for calling Dom::begin_widget immediately followed by Dom::end_widget.

Source

pub fn begin_widget<T: Widget>( &self, props: T::Props<'_>, ) -> Response<T::Response>

Begin building a widget with the given type and props.

After calling this method, children can be added to this widget.

Source

pub fn end_widget<T: Widget>(&self, id: WidgetId)

Finish building the widget with the given ID. Must be the top of the stack, with no other widgets pending.

Trait Implementations§

Source§

impl Debug for Dom

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Dom

§

impl !RefUnwindSafe for Dom

§

impl !Send for Dom

§

impl !Sync for Dom

§

impl Unpin for Dom

§

impl !UnwindSafe for Dom

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>,

Source§

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>,

Source§

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.
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> Props for T
where T: Debug,