pub struct CoreIR {
pub nodes: HashMap<NodeId, CoreNode>,
pub root: Option<NodeId>,
}Expand description
The root container for an intermediate representation graph.
CoreIR owns all nodes in the tree and knows which one is the root. It is the
primary data structure you build when compiling a widget tree, and the primary
input to the layout engine.
§Example
use fission_ir::{CoreIR, NodeId, Op, LayoutOp};
let mut ir = CoreIR::new();
let root = NodeId::explicit("root");
ir.add_node(root, Op::Layout(LayoutOp::Box {
width: None, height: None,
min_width: None, max_width: None,
min_height: None, max_height: None,
padding: [0.0; 4], flex_grow: 1.0, flex_shrink: 1.0,
aspect_ratio: None,
}), vec![]);
ir.set_root(root);
assert!(ir.root.is_some());Fields§
§nodes: HashMap<NodeId, CoreNode>All nodes in the graph, keyed by their NodeId.
root: Option<NodeId>The root node of the tree, or None if the tree is empty.
Implementations§
Source§impl CoreIR
impl CoreIR
Sourcepub fn add_node(&mut self, id: NodeId, op: Op, children: Vec<NodeId>)
pub fn add_node(&mut self, id: NodeId, op: Op, children: Vec<NodeId>)
Adds a node to the graph and wires up parent-child relationships.
Each child in children that already exists in the graph will have its
parent field set to id. Add children before their parents to ensure
the parent link is established.
§Arguments
id– The identity of the new node.op– What this node does (layout, paint, structural, or semantics).children– Ordered list of childNodeIds.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CoreIR
impl<'de> Deserialize<'de> for CoreIR
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for CoreIR
Auto Trait Implementations§
impl Freeze for CoreIR
impl RefUnwindSafe for CoreIR
impl Send for CoreIR
impl Sync for CoreIR
impl Unpin for CoreIR
impl UnsafeUnpin for CoreIR
impl UnwindSafe for CoreIR
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more