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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use crate::{
constants::{ResourceType, ReturnCode},
objects::{OwnedStructure, RoomObject, Store, Structure},
prelude::*,
RoomName,
};
use js_sys::JsString;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(extends = RoomObject, extends = Structure, extends = OwnedStructure)]
#[derive(Clone, Debug)]
pub type StructureTerminal;
#[wasm_bindgen(method, getter)]
pub fn cooldown(this: &StructureTerminal) -> u32;
#[wasm_bindgen(method, getter)]
pub fn store(this: &StructureTerminal) -> Store;
#[wasm_bindgen(method, js_name = send)]
fn send_internal(
this: &StructureTerminal,
resource_type: ResourceType,
amount: u32,
destination: &JsString,
description: Option<&JsString>,
) -> ReturnCode;
}
impl StructureTerminal {
pub fn send(
&self,
resource_type: ResourceType,
amount: u32,
destination: RoomName,
description: Option<&str>,
) -> ReturnCode {
let desination = destination.into();
let description = description.map(JsString::from);
Self::send_internal(
self,
resource_type,
amount,
&desination,
description.as_ref(),
)
}
}
impl HasCooldown for StructureTerminal {
fn cooldown(&self) -> u32 {
Self::cooldown(self)
}
}
impl HasStore for StructureTerminal {
fn store(&self) -> Store {
Self::store(self)
}
}