Skip to main content

CoreIR

Struct CoreIR 

Source
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

Source

pub fn new() -> Self

Creates an empty IR with no nodes and no root.

Source

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 child NodeIds.
Source

pub fn set_root(&mut self, id: NodeId)

Designates a node as the root of the tree.

The layout engine starts traversal from this node. There must be exactly one root; calling this again replaces the previous root.

Trait Implementations§

Source§

impl Clone for CoreIR

Source§

fn clone(&self) -> CoreIR

Returns a duplicate 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 Debug for CoreIR

Source§

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

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

impl Default for CoreIR

Source§

fn default() -> CoreIR

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

impl<'de> Deserialize<'de> for CoreIR

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CoreIR

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Serialize for CoreIR

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CoreIR

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, 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,