beetry_core/root.rs
1use crate::{Node, TickStatus};
2
3/// Root node.
4///
5/// `Root` owns the top-level child node and forwards the [`Node`] lifecycle to
6/// it.
7pub struct Root<N> {
8 child: N,
9}
10
11impl<N> Root<N>
12where
13 N: Node,
14{
15 pub fn new(child: N) -> Self {
16 Self { child }
17 }
18}
19
20impl<N> Node for Root<N>
21where
22 N: Node,
23{
24 fn tick(&mut self) -> TickStatus {
25 self.child.tick()
26 }
27
28 fn reset(&mut self) {
29 self.child.reset();
30 }
31
32 fn abort(&mut self) {
33 self.child.abort();
34 }
35}