Skip to main content

Container

Struct Container 

Source
pub struct Container {
Show 64 fields pub id: usize, pub str_id: Option<String>, pub classes: Vec<String>, pub data: BTreeMap<String, String>, pub element: Element, pub children: Vec<Container>, pub direction: LayoutDirection, pub overflow_x: LayoutOverflow, pub overflow_y: LayoutOverflow, pub grid_cell_size: Option<Number>, pub justify_content: Option<JustifyContent>, pub align_items: Option<AlignItems>, pub text_align: Option<TextAlign>, pub white_space: Option<WhiteSpace>, pub text_decoration: Option<TextDecoration>, pub font_family: Option<Vec<String>>, pub font_weight: Option<FontWeight>, pub width: Option<Number>, pub min_width: Option<Number>, pub max_width: Option<Number>, pub height: Option<Number>, pub min_height: Option<Number>, pub max_height: Option<Number>, pub flex: Option<Flex>, pub column_gap: Option<Number>, pub row_gap: Option<Number>, pub opacity: Option<Number>, pub left: Option<Number>, pub right: Option<Number>, pub top: Option<Number>, pub bottom: Option<Number>, pub translate_x: Option<Number>, pub translate_y: Option<Number>, pub cursor: Option<Cursor>, pub user_select: Option<UserSelect>, pub overflow_wrap: Option<OverflowWrap>, pub text_overflow: Option<TextOverflow>, pub position: Option<Position>, pub background: Option<Color>, pub border_top: Option<(Color, Number)>, pub border_right: Option<(Color, Number)>, pub border_bottom: Option<(Color, Number)>, pub border_left: Option<(Color, Number)>, pub border_top_left_radius: Option<Number>, pub border_top_right_radius: Option<Number>, pub border_bottom_left_radius: Option<Number>, pub border_bottom_right_radius: Option<Number>, pub margin_left: Option<Number>, pub margin_right: Option<Number>, pub margin_top: Option<Number>, pub margin_bottom: Option<Number>, pub padding_left: Option<Number>, pub padding_right: Option<Number>, pub padding_top: Option<Number>, pub padding_bottom: Option<Number>, pub font_size: Option<Number>, pub color: Option<Color>, pub state: Option<Value>, pub hidden: Option<bool>, pub debug: Option<bool>, pub visibility: Option<Visibility>, pub route: Option<Route>, pub actions: Vec<Action>, pub overrides: Vec<ConfigOverride>,
}
Expand description

Represents a layout container with style properties and child elements.

The main building block for constructing UI layouts. Contains all layout and styling properties needed for rendering, along with child containers forming a tree structure.

Fields§

§id: usize

Unique numeric identifier.

§str_id: Option<String>

Optional string identifier.

§classes: Vec<String>

CSS class names.

§data: BTreeMap<String, String>

Custom data attributes.

§element: Element

Element type and content.

§children: Vec<Container>

Child containers.

§direction: LayoutDirection

Layout direction (row or column).

§overflow_x: LayoutOverflow

Horizontal overflow behavior.

§overflow_y: LayoutOverflow

Vertical overflow behavior.

§grid_cell_size: Option<Number>

Grid cell size for grid layouts.

§justify_content: Option<JustifyContent>

Main axis alignment (flex-start, center, space-between, etc.).

§align_items: Option<AlignItems>

Cross axis alignment (flex-start, center, stretch, etc.).

§text_align: Option<TextAlign>

Text alignment (left, center, right, justify).

§white_space: Option<WhiteSpace>

White space handling (normal, nowrap, pre, etc.).

§text_decoration: Option<TextDecoration>

Text decoration styling.

§font_family: Option<Vec<String>>

Font family list.

§font_weight: Option<FontWeight>

Font weight.

§width: Option<Number>

Width of the container.

§min_width: Option<Number>

Minimum width constraint.

§max_width: Option<Number>

Maximum width constraint.

§height: Option<Number>

Height of the container.

§min_height: Option<Number>

Minimum height constraint.

§max_height: Option<Number>

Maximum height constraint.

§flex: Option<Flex>

Flex sizing (grow, shrink, basis).

§column_gap: Option<Number>

Gap between columns in flex/grid layouts.

§row_gap: Option<Number>

Gap between rows in flex/grid layouts.

§opacity: Option<Number>

Opacity (0.0 to 1.0).

§left: Option<Number>

Left position for positioned elements.

§right: Option<Number>

Right position for positioned elements.

§top: Option<Number>

Top position for positioned elements.

§bottom: Option<Number>

Bottom position for positioned elements.

§translate_x: Option<Number>

Horizontal translation transform.

§translate_y: Option<Number>

Vertical translation transform.

§cursor: Option<Cursor>

Cursor style.

§user_select: Option<UserSelect>

User selection behavior.

§overflow_wrap: Option<OverflowWrap>

Text wrapping behavior.

§text_overflow: Option<TextOverflow>

Text overflow handling.

§position: Option<Position>

Position type (static, relative, absolute, fixed).

§background: Option<Color>

Background color.

§border_top: Option<(Color, Number)>

Top border (color and width).

§border_right: Option<(Color, Number)>

Right border (color and width).

§border_bottom: Option<(Color, Number)>

Bottom border (color and width).

§border_left: Option<(Color, Number)>

Left border (color and width).

§border_top_left_radius: Option<Number>

Top-left border radius.

§border_top_right_radius: Option<Number>

Top-right border radius.

§border_bottom_left_radius: Option<Number>

Bottom-left border radius.

§border_bottom_right_radius: Option<Number>

Bottom-right border radius.

§margin_left: Option<Number>

Left margin.

§margin_right: Option<Number>

Right margin.

§margin_top: Option<Number>

Top margin.

§margin_bottom: Option<Number>

Bottom margin.

§padding_left: Option<Number>

Left padding.

§padding_right: Option<Number>

Right padding.

§padding_top: Option<Number>

Top padding.

§padding_bottom: Option<Number>

Bottom padding.

§font_size: Option<Number>

Font size.

§color: Option<Color>

Text color.

§state: Option<Value>

Custom state data for dynamic behavior.

§hidden: Option<bool>

Whether the container is hidden.

§debug: Option<bool>

Whether to render debug information.

§visibility: Option<Visibility>

CSS visibility property.

§route: Option<Route>

Associated route for navigation.

§actions: Vec<Action>

Interactive actions bound to this container.

§overrides: Vec<ConfigOverride>

Conditional style overrides.

Implementations§

Source§

impl Container

Source

pub fn iter_overrides( &self, recurse: bool, ) -> impl Iterator<Item = (&Container, &ConfigOverride)>

Returns an iterator over config overrides for this container and optionally its children.

§Parameters
  • recurse - If true, includes overrides from all descendant containers
Source

pub fn bfs(&self) -> BfsPaths

Creates a breadth-first search iterator for traversing the container tree.

Returns a BfsPaths structure that can be used to traverse containers level by level.

Source

pub fn bfs_visit(&self, visitor: impl FnMut(&Container)) -> BfsPaths

Performs a breadth-first search traversal with a visitor function.

Calls the visitor function for each container in breadth-first order.

Source

pub fn bfs_visit_mut(&mut self, visitor: impl FnMut(&mut Container)) -> BfsPaths

Performs a breadth-first search traversal with a mutable visitor function.

Calls the visitor function for each container in breadth-first order, allowing mutation.

Source§

impl Container

Source

pub const fn is_fixed(&self) -> bool

Checks if this container has fixed or sticky positioning.

Returns true if the container’s position is set to Position::Fixed or Position::Sticky, which removes it from the normal document flow and positions it relative to the viewport or scroll container.

Source

pub const fn is_raw(&self) -> bool

Checks if this container contains raw HTML content.

Returns true if the element is Element::Raw, which means it contains unescaped HTML that will be rendered directly without further processing.

For escaped text content, see Self::is_text.

Source

pub const fn is_text(&self) -> bool

Checks if this container contains escaped text content.

Returns true if the element is Element::Text, which means it contains text that will be HTML-escaped when rendered to prevent XSS attacks.

For raw unescaped HTML content, see Self::is_raw.

Source§

impl Container

Source

pub fn is_visible(&self) -> bool

Checks if this container is visible (not hidden).

Source

pub fn is_hidden(&self) -> bool

Checks if this container is hidden.

Source

pub fn is_span(&self) -> bool

Checks if this container is a span element.

Source

pub fn is_flex_container(&self) -> bool

Checks if this container uses flexbox layout.

Source

pub fn visible_elements(&self) -> impl Iterator<Item = &Container>

Returns an iterator over visible child elements.

Source

pub fn visible_elements_mut(&mut self) -> impl Iterator<Item = &mut Container>

Returns a mutable iterator over visible child elements.

Source

pub fn relative_positioned_elements(&self) -> impl Iterator<Item = &Container>

Returns an iterator over relatively positioned child elements.

Source

pub fn relative_positioned_elements_mut( &mut self, ) -> impl Iterator<Item = &mut Container>

Returns a mutable iterator over relatively positioned child elements.

Source

pub fn absolute_positioned_elements(&self) -> impl Iterator<Item = &Container>

Returns an iterator over absolutely positioned child elements.

Source

pub fn absolute_positioned_elements_mut( &mut self, ) -> impl Iterator<Item = &mut Container>

Returns a mutable iterator over absolutely positioned child elements.

Source

pub fn fixed_positioned_elements(&self) -> impl Iterator<Item = &Container>

Returns an iterator over fixed positioned child elements.

Source

pub fn fixed_positioned_elements_mut( &mut self, ) -> impl Iterator<Item = &mut Container>

Returns a mutable iterator over fixed positioned child elements.

Source

pub fn find_element_by_id(&self, id: usize) -> Option<&Container>

Finds a descendant container by its numeric ID.

Source

pub fn find_element_by_id_mut(&mut self, id: usize) -> Option<&mut Container>

Finds a descendant container by its numeric ID (mutable).

Source

pub fn find_element_by_str_id(&self, str_id: &str) -> Option<&Container>

Finds a descendant container by its string ID.

Source

pub fn find_element_by_class(&self, class: &str) -> Option<&Container>

Finds a descendant container by CSS class name.

Source

pub fn find_element_by_str_id_mut( &mut self, str_id: &str, ) -> Option<&mut Container>

Finds a descendant container by its string ID (mutable).

Source

pub fn find_parent<'a>(&self, root: &'a mut Container) -> Option<&'a Container>

Finds the parent container of this container within the root tree.

Source

pub fn find_parent_by_id(&self, id: usize) -> Option<&Container>

Finds the parent container of a child with the given numeric ID.

Source

pub fn find_parent_by_id_mut(&mut self, id: usize) -> Option<&mut Container>

Finds the parent container of a child with the given numeric ID (mutable).

Source

pub fn find_parent_by_str_id_mut(&mut self, id: &str) -> Option<&mut Container>

Finds the parent container of a child with the given string ID (mutable).

Source

pub fn replace_with_elements( &mut self, replacement: Vec<Container>, root: &mut Container, ) -> Container

Replaces this container with multiple elements in the tree.

Finds this container’s parent in the tree and replaces this container with the provided replacement elements. Returns the original container that was replaced.

§Panics
  • If the Container is the root node
  • If the Container is not properly attached to the tree
Source

pub fn replace_id_children_with_elements( &mut self, replacement: Vec<Container>, id: usize, ) -> Option<Vec<Container>>

Replaces all children of a container identified by numeric ID.

Finds the container with the given ID and replaces all of its children with the provided replacement elements. Returns the original children that were replaced, or None if no container with the given ID exists.

§Panics
  • If the Container is not properly attached to the tree
Source

pub fn replace_str_id_children_with_elements( &mut self, replacement: Vec<Container>, id: &str, ) -> Option<Vec<Container>>

Replaces all children of a container identified by string ID.

Finds the container with the given string ID and replaces all of its children with the provided replacement elements. Returns the original children that were replaced, or None if no container with the given string ID exists.

§Panics
  • If the Container is not properly attached to the tree
Source

pub fn replace_id_with_elements( &mut self, replacement: Vec<Container>, id: usize, ) -> Option<Container>

Replaces a container identified by numeric ID with multiple elements.

Finds the container with the given ID and replaces it with the provided replacement elements. Returns the original container that was replaced, or None if no container with the given ID exists.

§Panics
  • If the Container is not properly attached to the tree
Source

pub fn replace_str_id_with_elements( &mut self, replacement: Vec<Container>, id: &str, ) -> Option<Container>

Replaces a container identified by string ID with multiple elements.

Finds the container with the given string ID and replaces it with the provided replacement elements. Returns the original container that was replaced, or None if no container with the given string ID exists.

§Panics
  • If the Container is not properly attached to the tree
Source§

impl Container

Source

pub fn display_to_string_default( &self, with_debug_attrs: bool, wrap_raw_in_element: bool, ) -> Result<String, Box<dyn Error>>

Converts this container to an HTML string with default formatting.

Generates HTML representation of the container and its children with basic options. For more control over formatting and syntax highlighting, use display_to_string.

§Errors
  • If fails to write to the writer
  • If invalid UTF-8 characters
Source

pub fn display_to_string_default_pretty( &self, with_debug_attrs: bool, wrap_raw_in_element: bool, ) -> Result<String, Box<dyn Error>>

Converts this container to a formatted HTML string with syntax highlighting.

Generates HTML representation of the container and its children with pretty formatting and syntax highlighting enabled (if the respective features are enabled).

§Errors
  • If fails to write to the writer
  • If invalid UTF-8 characters
Source

pub fn display_to_string( &self, with_debug_attrs: bool, wrap_raw_in_element: bool, format: bool, ) -> Result<String, Box<dyn Error>>

Converts this container to an HTML string with full formatting control.

Generates HTML representation of the container and its children with options for debug attributes, raw element wrapping, formatting, and syntax highlighting.

§Errors
  • If fails to write to the writer
  • If invalid UTF-8 characters
§Panics
  • If syntax highlighting fails
Source§

impl Container

Source

pub fn table_iter<'a, 'b>(&'a self) -> TableIter<'b>
where 'a: 'b,

Creates an iterator over table rows and heading cells.

Returns a TableIter that provides iterators over the table’s heading row (if present) and body rows. Each row iterator yields individual cell containers.

§Panics

Will panic if Element is not a table

Source

pub fn table_iter_mut<'a, 'b>(&'a mut self) -> TableIterMut<'b>
where 'a: 'b,

Creates a mutable iterator over table rows and heading cells.

Returns a TableIterMut that provides mutable iterators over the table’s heading row (if present) and body rows. Each row iterator yields mutable references to cell containers.

§Panics

Will panic if Element is not a table

Source

pub fn table_iter_mut_with_observer<'a, 'b>( &'a mut self, observer: Option<impl FnMut(&mut Container)>, ) -> TableIterMut<'b>
where 'a: 'b,

Creates a mutable iterator over table rows with an observer callback.

Returns a TableIterMut that provides mutable iterators over the table’s heading row (if present) and body rows. The optional observer function is called for each row element during iteration, allowing for side effects or validation.

§Panics

Will panic if Element is not a table

Trait Implementations§

Source§

impl AsRef<Container> for Container

Source§

fn as_ref(&self) -> &Container

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Container

Source§

fn clone(&self) -> Container

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Container

Source§

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

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

impl Default for Container

Source§

fn default() -> Container

Returns the “default value” for a type. Read more
Source§

impl Display for Container

Source§

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

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

impl From<Vec<Container>> for Container

Source§

fn from(value: Vec<Container>) -> Container

Converts to this type from the input type.
Source§

impl PartialEq for Container

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<&'a str> for Container

Source§

type Error = ParseError

The type returned in the event of a conversion error.
Source§

fn try_from( value: &'a str, ) -> Result<Container, <Container as TryFrom<&'a str>>::Error>

Performs the conversion.
Source§

impl TryFrom<String> for Container

Source§

type Error = ParseError

The type returned in the event of a conversion error.
Source§

fn try_from( value: String, ) -> Result<Container, <Container as TryFrom<String>>::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Container

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V