Struct lignin::Element[][src]

pub struct Element<'a, S: ThreadSafety> {
    pub name: &'a str,
    pub creation_options: ElementCreationOptions<'a>,
    pub attributes: &'a [Attribute<'a>],
    pub content: Node<'a, S>,
    pub event_bindings: &'a [EventBinding<'a, S>],
}

Vdom Represents a single HTMLElement as name, attributes, content and event_bindings.

Fields

name: &'a str

The Element.tag_name.

Unlike in the browser, this is generally treated case-sensitively, meaning for example "div" doesn’t equal "DIV".

Since browsers will generally return the canonical uppercase name, it’s recommended to generate the VDOM all-uppercase too, to avoid unnecessary mismatches.

creation_options: ElementCreationOptions<'a>

Controls the options parameter of Document.createElement() or (currently only) the global is attribute.

attributes: &'a [Attribute<'a>]

The Element.attributes.

Note that while this collection is unordered in the browser, reordering attributes will generally affect diffing performance.

content: Node<'a, S>

Maps to Node.childNodes.

event_bindings: &'a [EventBinding<'a, S>]

DOM event bindings requested by a component.

See EventBinding for more information.

Implementations

impl<'a, S: ThreadSafety> Element<'a, S>[src]

#[must_use]
pub fn deanonymize(self) -> Self
[src]

👎 Deprecated:

Call of .deanonymize() on named type.

When called on an opaque type, deanonymizes it into the underlying named type.

Both AutoSafe and Deanonymize must be in scope and the method must be called without qualification for this to work.

Calling this method on a named type returns the value and type unchanged and produces a deprecation warning.

impl<'a> Element<'a, ThreadSafe>[src]

#[must_use]
pub fn prefer_thread_safe(self) -> Self
[src]

Gently nudges the compiler to choose the ThreadSafe version of a value if both are possible.

This method is by value, so it will resolve with higher priority than the by-reference method on the ThreadBound type.

Note that not all tooling will show the correct overload here, but the compiler knows which to pick.

#[must_use]
pub fn prefer_thread_safe_ref(&self) -> &Self
[src]

Gently nudges the compiler to choose the ThreadSafe version of a reference if both are possible.

This method is once by single reference, so it will resolve with higher priority than the twice-by-reference method on the ThreadBound type.

Note that not all tooling will show the correct overload here, but the compiler knows which to pick.

impl<'a> Element<'a, ThreadBound>[src]

#[must_use]
pub fn prefer_thread_safe(&self) -> Self
[src]

Gently nudges the compiler to choose the ThreadSafe version of a value if both are is possible.

This method is by reference, so it will resolve with lower priority than the by-value method on the ThreadSafe type.

Note that not all tooling will show the correct overload here, but the compiler knows which to pick.

#[must_use]
pub fn prefer_thread_safe_ref<'b>(self: &&'b Self) -> &'b Self
[src]

Gently nudges the compiler to choose the ThreadSafe version of a reference if both are is possible.

This method is twice by reference, so it will resolve with lower priority than the once-by-reference method on the ThreadSafe type.

Note that not all tooling will show the correct overload here, but the compiler knows which to pick.

impl<'a, S> Element<'a, S> where
    S: ThreadSafety
[src]

#[must_use]
pub fn as_html(&'a self) -> Node<'a, S>
[src]

Wraps a reference to this Element inside a Node::HtmlElement without dom_binding.

Example

use lignin::{ElementCreationOptions, Node, ThreadSafe};

fn allocate<'a, T>(value: T) -> &'a T {
  // […]
}

let html_node: Node<ThreadSafe> = allocate(lignin::Element {
  name: "DIV",
  creation_options: ElementCreationOptions::new(),
  attributes: &[],
  content: Node::Multi(&[]),
  event_bindings: &[],
}).as_html();

#[must_use]
pub fn as_svg(&'a self) -> Node<'a, S>
[src]

Wraps a reference to this Element inside a Node::SvgElement without dom_binding.

Example

use lignin::{ElementCreationOptions, Node, ThreadSafe};

fn allocate<'a, T>(value: T) -> &'a T {
  // […]
}

let svg_node: Node<ThreadSafe> = allocate(lignin::Element {
  name: "SVG",
  creation_options: ElementCreationOptions::new(),
  attributes: &[],
  content: Node::Multi(&[]),
  event_bindings: &[],
}).as_svg();

Trait Implementations

impl<'a, S1, S2> Align<Element<'a, S2>> for Element<'a, S1> where
    S1: ThreadSafety + Into<S2>,
    S2: ThreadSafety
[src]

Not derived from the Into constraints on $Name directly since those are too broad.

impl<'a, S> Clone for Element<'a, S> where
    S: ThreadSafety
[src]

impl<'a, S> Copy for Element<'a, S> where
    S: ThreadSafety
[src]

impl<'a, V> Deanonymize<Element<'a, ThreadSafe>> for V where
    V: Send + Sync + AutoSafe<Element<'a, ThreadBound>>, 
[src]

impl<'a, S> Debug for Element<'a, S> where
    S: ThreadSafety
[src]

impl<'a, S> Eq for Element<'a, S> where
    S: ThreadSafety
[src]

impl<'a> From<Element<'a, ThreadSafe>> for Element<'a, ThreadBound>[src]

impl<'a, S> Hash for Element<'a, S> where
    S: ThreadSafety
[src]

impl<'a, S> Ord for Element<'a, S> where
    S: ThreadSafety
[src]

impl<'a, S1, S2> PartialEq<Element<'a, S2>> for Element<'a, S1> where
    S1: ThreadSafety,
    S2: ThreadSafety
[src]

impl<'a, S1, S2> PartialOrd<Element<'a, S2>> for Element<'a, S1> where
    S1: ThreadSafety,
    S2: ThreadSafety
[src]

impl<'a, S> Vdom for Element<'a, S> where
    S: ThreadSafety
[src]

type ThreadSafety = S

The ThreadSafety of the Vdom type, either ThreadSafe or ThreadBound. Read more

Auto Trait Implementations

impl<'a, S> RefUnwindSafe for Element<'a, S> where
    S: RefUnwindSafe

impl<'a, S> Send for Element<'a, S> where
    S: Send + Sync

impl<'a, S> Sync for Element<'a, S> where
    S: Sync

impl<'a, S> Unpin for Element<'a, S> where
    S: Unpin

impl<'a, S> UnwindSafe for Element<'a, S> where
    S: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<'a, S, T> AutoSafe<T> for S where
    S: Vdom + Align<T>,
    T: Vdom<ThreadSafety = ThreadBound>, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, V> Deanonymize<Element<'a, ThreadSafe>> for V where
    V: Send + Sync + AutoSafe<Element<'a, ThreadBound>>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.