orbit/
component_single.rs1use crate::component::ComponentInstance;
2use crate::events::EventEmitter;
3use crate::state::StateContainer;
4use std::collections::HashMap;
5
6#[derive(Clone, Debug)]
8pub struct Context {
9 #[allow(dead_code)]
11 state: StateContainer,
12
13 #[allow(dead_code)]
15 events: EventEmitter,
16}
17
18#[allow(dead_code)]
20pub struct Node {
21 component: Option<ComponentInstance>,
23
24 attributes: HashMap<String, String>,
26
27 children: Vec<Node>,
29
30 id: usize,
32}
33
34impl Node {
35 pub fn children(&self) -> &[Node] {
37 &self.children
38 }
39
40 pub fn children_mut(&mut self) -> &mut Vec<Node> {
42 &mut self.children
43 }
44
45 pub fn id_value(&self) -> usize {
47 self.id
48 }
49}
50
51impl Default for Node {
52 fn default() -> Self {
53 static mut NEXT_ID: usize = 0;
54 let id = unsafe {
55 let id = NEXT_ID;
56 NEXT_ID += 1;
57 id
58 };
59
60 Self {
61 component: None,
62 attributes: HashMap::new(),
63 children: Vec::new(),
64 id,
65 }
66 }
67}