screeps/objects/impls/
structure_link.rs1use wasm_bindgen::prelude::*;
2
3use crate::{
4    enums::action_error_codes::structure_link::*,
5    objects::{OwnedStructure, RoomObject, Store, Structure},
6    prelude::*,
7};
8
9#[wasm_bindgen]
10extern "C" {
11    #[wasm_bindgen(extends = RoomObject, extends = Structure, extends = OwnedStructure)]
16    #[derive(Clone, Debug)]
17    pub type StructureLink;
18
19    #[wasm_bindgen(method, getter)]
24    pub fn cooldown(this: &StructureLink) -> u32;
25
26    #[wasm_bindgen(method, getter)]
31    pub fn store(this: &StructureLink) -> Store;
32
33    #[wasm_bindgen(method, js_name = transferEnergy)]
34    fn transfer_energy_internal(
35        this: &StructureLink,
36        target: &StructureLink,
37        amount: Option<u32>,
38    ) -> i8;
39}
40
41impl StructureLink {
42    pub fn transfer_energy(
51        &self,
52        target: &StructureLink,
53        amount: Option<u32>,
54    ) -> Result<(), TransferEnergyErrorCode> {
55        TransferEnergyErrorCode::result_from_i8(self.transfer_energy_internal(target, amount))
56    }
57}
58
59impl HasCooldown for StructureLink {
60    fn cooldown(&self) -> u32 {
61        Self::cooldown(self)
62    }
63}
64
65impl HasStore for StructureLink {
66    fn store(&self) -> Store {
67        Self::store(self)
68    }
69}
70
71impl Attackable for StructureLink {}
72impl Dismantleable for StructureLink {}
73impl Repairable for StructureLink {}
74impl Transferable for StructureLink {}
75impl Withdrawable for StructureLink {}