1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Lowering traits for converting widgets into the intermediate representation.
use crateLoweringContext;
use NodeId;
use Debug;
/// Converts a widget struct into `fission-ir` nodes.
///
/// Every built-in widget implements `Lower`. The method receives a
/// [`LoweringContext`] and returns the root [`NodeId`] of the emitted IR
/// subgraph.
/// Object-safe variant of [`Lower`] for use inside [`CustomNode`](crate::ui::CustomNode).
///
/// Implement this trait when you need custom lowering logic that cannot be
/// expressed with the built-in widget primitives.
///
/// # Example
///
/// ```rust,ignore
/// #[derive(Debug)]
/// struct MyCanvasLowerer;
///
/// impl LowerDyn for MyCanvasLowerer {
/// fn lower_dyn(&self, cx: &mut LoweringContext) -> NodeId {
/// // emit custom IR nodes...
/// cx.next_node_id()
/// }
///
/// fn stable_key(&self) -> u64 {
/// 0xCAFE
/// }
/// }
/// ```