1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
use { constants::{ReturnCode, StructureType}, objects::ConstructionSite, traits::TryInto, }; simple_accessors! { ConstructionSite; (my -> my -> bool), (progress -> progress -> u32), (progress_total -> progressTotal -> u32), (structure_type -> structureType -> StructureType), } impl ConstructionSite { pub fn owner_name(&self) -> String { (js! { var self = @{self.as_ref()}; if (self.owner) { return self.owner.username; } else { return null; } }) .try_into() .expect("expected ConstructionSite.owner.username to be a non-null string") } pub fn remove(&self) -> ReturnCode { js_unwrap!(@{self.as_ref()}.remove()) } }