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 use cfg_if::cfg_if; 6 use core::ops::Deref; 7 use core::result::Result::{self, Err, Ok}; 8 #[cfg(target_os = "dragonos")] 9 use drstd as std; 10 use std::marker::{Send, Sized, Sync}; 11 use std::rc::Rc; 12 use std::sync::Arc; 13 use std::vec::Vec; 14 15 #[derive(Debug, Clone, Default)] 16 pub struct TargetUnit { 17 unit_base: BaseUnit, 18 //targets: Vec<Rc<dyn Unit>>, 19 } 20 21 impl Unit for TargetUnit { 22 fn as_any(&self) -> &dyn core::any::Any { 23 self 24 } 25 26 fn from_path(path: &str) -> Result<usize, ParseError> 27 where 28 Self: Sized, 29 { 30 return TargetParser::parse(path); 31 } 32 33 fn set_attr(&mut self, segement: Segment, attr: &str, val: &str) -> Result<(), ParseError> { 34 Ok(()) 35 } 36 37 fn set_unit_base(&mut self, base: BaseUnit) { 38 self.unit_base = base; 39 } 40 41 fn unit_type(&self) -> super::UnitType { 42 return self.unit_base.unit_type; 43 } 44 45 fn unit_base(&self) -> &BaseUnit { 46 return &self.unit_base; 47 } 48 49 fn unit_id(&self) -> usize { 50 return self.unit_base.unit_id; 51 } 52 53 fn run(&mut self) -> Result<(), crate::error::runtime_error::RuntimeError> { 54 Ok(()) 55 } 56 57 fn mut_unit_base(&mut self) -> &mut BaseUnit { 58 return &mut self.unit_base; 59 } 60 } 61 62 unsafe impl Sync for TargetUnit {} 63 64 unsafe impl Send for TargetUnit {} 65