Enum sauron_core::vdom::leaf::Leaf

source ·
pub enum Leaf<MSG> {
    Text(String),
    SafeHtml(String),
    Comment(String),
    Fragment(Vec<Node<MSG>>),
    DocType(String),
}
Expand description

A leaf node value of html dom tree

Variants§

§

Text(String)

Text variant of a virtual node

§

SafeHtml(String)

A safe html variant

§

Comment(String)

A comment node

§

Fragment(Vec<Node<MSG>>)

a vec of nodes

§

DocType(String)

Implementations§

source§

impl<MSG> Leaf<MSG>

source

pub fn is_text(&self) -> bool

returns true if this a text node

source

pub fn is_safe_html(&self) -> bool

returns true if this is a safe html text node

source

pub fn unwrap_text(&self) -> &str

unwrap the text content if this a text node, panics if it is not a text node

source

pub fn unwrap_safe_html(&self) -> &str

unwrap the text content if this a text node, panics if it is not a text node

Trait Implementations§

source§

impl<MSG> Clone for Leaf<MSG>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<MSG> Debug for Leaf<MSG>

source§

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

Formats the value using the given formatter. Read more
source§

impl<MSG> PartialEq<Leaf<MSG>> for Leaf<MSG>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<MSG> Render for Leaf<MSG>

source§

fn render_with_indent( &self, buffer: &mut dyn Write, indent: usize, compressed: bool ) -> Result

render instance to a writable buffer with indention
source§

fn render(&self, buffer: &mut dyn Write) -> Result

render the node to a writable buffer
source§

fn render_compressed(&self, buffer: &mut dyn Write) -> Result

no new_lines, no indents
source§

fn render_to_string(&self) -> String

render compressed html to string
source§

fn render_to_string_pretty(&self) -> String

render to string with nice indention
source§

fn maybe_indent( &self, buffer: &mut dyn Write, indent: usize, compressed: bool ) -> Result

add an indent if applicable

Auto Trait Implementations§

§

impl<MSG> !RefUnwindSafe for Leaf<MSG>

§

impl<MSG> !Send for Leaf<MSG>

§

impl<MSG> !Sync for Leaf<MSG>

§

impl<MSG> Unpin for Leaf<MSG>

§

impl<MSG> !UnwindSafe for Leaf<MSG>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.