Skip to main content

Algorithm

Trait Algorithm 

Source
pub trait Algorithm {
    type Node: Copy + Clone + Hash + Eq;

    // Required methods
    fn new() -> Self;
    fn new_node(
        &mut self,
        style: ViewStyle,
        children: &[Self::Node],
    ) -> Self::Node;
    fn new_leaf(&mut self, style: ViewStyle, measure: MeasureFunc) -> Self::Node;
    fn add_child(&mut self, parent: Self::Node, child: Self::Node);
    fn remove_child(&mut self, parent: Self::Node, child: Self::Node);
    fn child_count(&self, parent: Self::Node) -> usize;
    fn remove(&mut self, node: Self::Node);
    fn set_style(&mut self, node: Self::Node, style: ViewStyle);
    fn set_measure(&mut self, node: Self::Node, measure: MeasureFunc);
    fn compute_layout(&mut self, node: Self::Node, size: Size<Dimension<f32>>);
    fn layout(&self, node: Self::Node) -> Layout;
}
Expand description

Abstract interface of a flexbox algorithm.

Required Associated Types§

Source

type Node: Copy + Clone + Hash + Eq

Represents the type of a node within this flexbox.

Required Methods§

Source

fn new() -> Self

Create a new instance of the flexbox (i.e. root).

Source

fn new_node(&mut self, style: ViewStyle, children: &[Self::Node]) -> Self::Node

Create a new node with the given child nodes.

Source

fn new_leaf(&mut self, style: ViewStyle, measure: MeasureFunc) -> Self::Node

Create a new leaf with an intrinsic content size that is determined by the given measure function.

Source

fn add_child(&mut self, parent: Self::Node, child: Self::Node)

Add a child node to a parent node.

Source

fn remove_child(&mut self, parent: Self::Node, child: Self::Node)

Remove a child node from a parent node.

Source

fn child_count(&self, parent: Self::Node) -> usize

Returns the number of child nodes of a specific parent node.

Source

fn remove(&mut self, node: Self::Node)

Removes the given node from this flexbox.

Source

fn set_style(&mut self, node: Self::Node, style: ViewStyle)

Updates the style of a specific node within this flexbox.

Source

fn set_measure(&mut self, node: Self::Node, measure: MeasureFunc)

Updates the measure function of a specific node within this flexbox.

Source

fn compute_layout(&mut self, node: Self::Node, size: Size<Dimension<f32>>)

Computes the layout of a node within this flexbox within the given size.

Source

fn layout(&self, node: Self::Node) -> Layout

Returns the computed layout of a node within this flexbox.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§