pub struct Dom {
pub root: NodeData,
pub children: Vec<Dom>,
/* private fields */
}
Expand description
The document model, similar to HTML. This is a create-only structure, you don’t actually read anything back
Fields§
§root: NodeData
§children: Vec<Dom>
Implementations§
Source§impl Dom
impl Dom
Sourcepub const fn new(node_type: NodeType) -> Self
pub const fn new(node_type: NodeType) -> Self
Creates an empty DOM with a give NodeType
. Note: This is a const fn
and
doesn’t allocate, it only allocates once you add at least one child node.
Sourcepub fn with_capacity(node_type: NodeType, cap: usize) -> Self
pub fn with_capacity(node_type: NodeType, cap: usize) -> Self
Creates an empty DOM with space reserved for cap
nodes
Sourcepub fn label<S: Into<DomString>>(value: S) -> Self
pub fn label<S: Into<DomString>>(value: S) -> Self
Shorthand for Dom::new(NodeType::Label(value.into()))
Sourcepub fn gl_texture<I: Into<RefAny>>(callback: GlCallbackType, ptr: I) -> Self
pub fn gl_texture<I: Into<RefAny>>(callback: GlCallbackType, ptr: I) -> Self
Shorthand for Dom::new(NodeType::GlTexture((callback, ptr)))
Sourcepub fn iframe<I: Into<RefAny>>(callback: IFrameCallbackType, ptr: I) -> Self
pub fn iframe<I: Into<RefAny>>(callback: IFrameCallbackType, ptr: I) -> Self
Shorthand for Dom::new(NodeType::IFrame((callback, ptr)))
Sourcepub fn with_id<S: Into<DomString>>(self, id: S) -> Self
pub fn with_id<S: Into<DomString>>(self, id: S) -> Self
Same as id
, but easier to use for method chaining in a builder-style pattern
Sourcepub fn with_class<S: Into<DomString>>(self, class: S) -> Self
pub fn with_class<S: Into<DomString>>(self, class: S) -> Self
Same as id
, but easier to use for method chaining in a builder-style pattern
Sourcepub fn with_callback<O: Into<EventFilter>>(
self,
on: O,
callback: CallbackType,
ptr: RefAny,
) -> Self
pub fn with_callback<O: Into<EventFilter>>( self, on: O, callback: CallbackType, ptr: RefAny, ) -> Self
Same as event
, but easier to use for method chaining in a builder-style pattern
pub fn with_child(self, child: Self) -> Self
pub fn with_css_override<S: Into<DomString>>( self, id: S, property: CssProperty, ) -> Self
pub fn with_tab_index(self, tab_index: TabIndex) -> Self
pub fn is_draggable(self, draggable: bool) -> Self
pub fn add_id<S: Into<DomString>>(&mut self, id: S)
pub fn add_class<S: Into<DomString>>(&mut self, class: S)
pub fn add_callback<O: Into<EventFilter>>( &mut self, on: O, callback: CallbackType, ptr: RefAny, )
pub fn add_css_override<S: Into<DomString>, P: Into<CssProperty>>( &mut self, override_id: S, property: P, )
pub fn set_tab_index(&mut self, tab_index: TabIndex)
pub fn set_draggable(&mut self, draggable: bool)
Sourcepub fn get_html_string(&self) -> String
pub fn get_html_string(&self) -> String
Returns a HTML-formatted version of the DOM for easier debugging, i.e.
Dom::div().with_id("hello")
.with_child(Dom::div().with_id("test"))
will return:
<div id="hello">
<div id="test" />
</div>
Trait Implementations§
Source§impl From<Dom> for CompactDom
impl From<Dom> for CompactDom
Source§impl FromIterator<Dom> for Dom
impl FromIterator<Dom> for Dom
Source§impl FromIterator<NodeData> for Dom
impl FromIterator<NodeData> for Dom
Source§impl FromIterator<NodeType> for Dom
impl FromIterator<NodeType> for Dom
impl Eq for Dom
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)