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 { 15 fn as_any(&self) -> &dyn core::any::Any { 16 self 17 } 18 19 fn from_path(path: &str) -> Result<usize, ParseError> 20 where 21 Self: Sized, 22 { 23 return TargetParser::parse(path); 24 } 25 26 fn set_attr(&mut self, _segement: Segment, _attr: &str, _val: &str) -> Result<(), ParseError> { 27 Ok(()) 28 } 29 30 fn set_unit_base(&mut self, base: BaseUnit) { 31 self.unit_base = base; 32 } 33 34 fn unit_type(&self) -> super::UnitType { 35 return self.unit_base.unit_type; 36 } 37 38 fn unit_base(&self) -> &BaseUnit { 39 return &self.unit_base; 40 } 41 42 fn unit_id(&self) -> usize { 43 return self.unit_base.unit_id; 44 } 45 46 fn run(&mut self) -> Result<(), crate::error::runtime_error::RuntimeError> { 47 Ok(()) 48 } 49 50 fn unit_base_mut(&mut self) -> &mut BaseUnit { 51 return &mut self.unit_base; 52 } 53 54 fn as_mut_any(&mut self) -> &mut dyn std::any::Any { 55 self 56 } 57 58 fn exit(&mut self) { 59 todo!() 60 } 61 } 62 63 unsafe impl Sync for TargetUnit {} 64 65 unsafe impl Send for TargetUnit {} 66