Skip to main content

Element

Enum Element 

Source
pub enum Element<Msg> {
    Box(BoxElement<Msg>),
    Text(TextElement),
    Spacer,
    _Phantom(PhantomData<Msg>),
}
Expand description

A node in the UI element tree.

Elements are the building blocks of the declarative UI. Use col![] and row![] macros for concise construction.

Variants§

§

Box(BoxElement<Msg>)

A container with Flexbox layout.

§

Text(TextElement)

Styled text content.

§

Spacer

Flexible space that expands to fill available room.

§

_Phantom(PhantomData<Msg>)

Implementations§

Source§

impl<Msg> Element<Msg>

Source

pub fn text(content: impl Into<String>) -> Self

Create a text element.

Source

pub fn is_box(&self) -> bool

Check if this is a Box element.

Source

pub fn is_text(&self) -> bool

Check if this is a Text element.

Source

pub fn is_spacer(&self) -> bool

Check if this is a Spacer.

Source

pub fn text_content(&self) -> Option<&str>

Get the text content if this is a Text element.

Source

pub fn children(&self) -> Option<&[Element<Msg>]>

Get the children if this is a Box element.

Source

pub fn child_count(&self) -> usize

Count total children (0 for non-Box elements).

Auto Trait Implementations§

§

impl<Msg> Freeze for Element<Msg>

§

impl<Msg> RefUnwindSafe for Element<Msg>
where Msg: RefUnwindSafe,

§

impl<Msg> Send for Element<Msg>
where Msg: Send,

§

impl<Msg> Sync for Element<Msg>
where Msg: Sync,

§

impl<Msg> Unpin for Element<Msg>
where Msg: Unpin,

§

impl<Msg> UnsafeUnpin for Element<Msg>

§

impl<Msg> UnwindSafe for Element<Msg>
where Msg: UnwindSafe,

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.