xref: /DragonReach/src/unit/target/mod.rs (revision dfd3fd9812f3584f9392934d1254e24d17661b2d)
1 use super::{BaseUnit, Unit};
2 use crate::error::parse_error::ParseError;
3 use crate::parse::parse_target::TargetParser;
4 use crate::parse::Segment;
5 
6 use core::result::Result::{self, Ok};
7 
8 #[derive(Debug, Clone, Default)]
9 pub struct TargetUnit {
10     unit_base: BaseUnit,
11     //targets: Vec<Rc<dyn Unit>>,
12 }
13 
14 impl Unit for TargetUnit {
as_any(&self) -> &dyn core::any::Any15     fn as_any(&self) -> &dyn core::any::Any {
16         self
17     }
18 
from_path(path: &str) -> Result<usize, ParseError> where Self: Sized,19     fn from_path(path: &str) -> Result<usize, ParseError>
20     where
21         Self: Sized,
22     {
23         return TargetParser::parse(path);
24     }
25 
set_attr(&mut self, _segement: Segment, _attr: &str, _val: &str) -> Result<(), ParseError>26     fn set_attr(&mut self, _segement: Segment, _attr: &str, _val: &str) -> Result<(), ParseError> {
27         Ok(())
28     }
29 
set_unit_base(&mut self, base: BaseUnit)30     fn set_unit_base(&mut self, base: BaseUnit) {
31         self.unit_base = base;
32     }
33 
unit_type(&self) -> super::UnitType34     fn unit_type(&self) -> super::UnitType {
35         return self.unit_base.unit_type;
36     }
37 
unit_base(&self) -> &BaseUnit38     fn unit_base(&self) -> &BaseUnit {
39         return &self.unit_base;
40     }
41 
unit_id(&self) -> usize42     fn unit_id(&self) -> usize {
43         return self.unit_base.unit_id;
44     }
45 
run(&mut self) -> Result<(), crate::error::runtime_error::RuntimeError>46     fn run(&mut self) -> Result<(), crate::error::runtime_error::RuntimeError> {
47         Ok(())
48     }
49 
unit_base_mut(&mut self) -> &mut BaseUnit50     fn unit_base_mut(&mut self) -> &mut BaseUnit {
51         return &mut self.unit_base;
52     }
53 
as_mut_any(&mut self) -> &mut dyn std::any::Any54     fn as_mut_any(&mut self) -> &mut dyn std::any::Any {
55         self
56     }
57 
exit(&mut self)58     fn exit(&mut self) {
59         todo!()
60     }
61 }
62 
63 unsafe impl Sync for TargetUnit {}
64 
65 unsafe impl Send for TargetUnit {}
66