gen_utils/compiler/model_node.rs
1use std::path::PathBuf;
2
3use proc_macro2::TokenStream;
4
5use crate::common::Source;
6
7/// # Model Node Impl
8/// Model Node is the basic unit of the model tree
9/// - each node can be a widget or a rs file or other kinds of file (depends on the project)
10/// - each node must has a source, which is the source trace of the node
11/// - each node must has a content, which is the content of the node (file content)
12pub trait ModelNodeImpl {
13 /// ## get mode node source
14 fn source(&self) -> Option<&Source>;
15 /// ## get content from the model node
16 fn content(&self) -> TokenStream;
17 /// ## get level from the model node
18 /// level is the depth of the node in the model tree
19 /// which is used to generate the file path of the node or compare with other nodes
20 fn level(&self) -> (usize, PathBuf);
21 /// ## compile the model node and write to file
22 fn compile(&self) -> ();
23}
24// : Clone + Hash + PartialEq + Eq