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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
use super::*;
/// The MIDIPort class.
/// [`MIDIPort`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct MIDIPort {
inner: EventTarget,
}
impl FromVal for MIDIPort {
fn from_val(v: &Any) -> Self {
MIDIPort {
inner: EventTarget::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for MIDIPort {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for MIDIPort {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for MIDIPort {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for MIDIPort {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<MIDIPort> for Any {
fn from(s: MIDIPort) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&MIDIPort> for Any {
fn from(s: &MIDIPort) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(MIDIPort);
impl MIDIPort {
/// Getter of the `id` attribute.
/// [`MIDIPort.id`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/id)
pub fn id(&self) -> JsString {
self.inner.get("id").as_::<JsString>()
}
}
impl MIDIPort {
/// Getter of the `manufacturer` attribute.
/// [`MIDIPort.manufacturer`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/manufacturer)
pub fn manufacturer(&self) -> JsString {
self.inner.get("manufacturer").as_::<JsString>()
}
}
impl MIDIPort {
/// Getter of the `name` attribute.
/// [`MIDIPort.name`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/name)
pub fn name(&self) -> JsString {
self.inner.get("name").as_::<JsString>()
}
}
impl MIDIPort {
/// Getter of the `type` attribute.
/// [`MIDIPort.type`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/type)
pub fn type_(&self) -> MIDIPortType {
self.inner.get("type").as_::<MIDIPortType>()
}
}
impl MIDIPort {
/// Getter of the `version` attribute.
/// [`MIDIPort.version`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/version)
pub fn version(&self) -> JsString {
self.inner.get("version").as_::<JsString>()
}
}
impl MIDIPort {
/// Getter of the `state` attribute.
/// [`MIDIPort.state`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/state)
pub fn state(&self) -> MIDIPortDeviceState {
self.inner.get("state").as_::<MIDIPortDeviceState>()
}
}
impl MIDIPort {
/// Getter of the `connection` attribute.
/// [`MIDIPort.connection`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/connection)
pub fn connection(&self) -> MIDIPortConnectionState {
self.inner
.get("connection")
.as_::<MIDIPortConnectionState>()
}
}
impl MIDIPort {
/// Getter of the `onstatechange` attribute.
/// [`MIDIPort.onstatechange`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/onstatechange)
pub fn onstatechange(&self) -> Any {
self.inner.get("onstatechange").as_::<Any>()
}
/// Setter of the `onstatechange` attribute.
/// [`MIDIPort.onstatechange`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/onstatechange)
pub fn set_onstatechange(&mut self, value: &Any) {
self.inner.set("onstatechange", value);
}
}
impl MIDIPort {
/// The open method.
/// [`MIDIPort.open`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/open)
pub fn open(&self) -> Promise<MIDIPort> {
self.inner.call("open", &[]).as_::<Promise<MIDIPort>>()
}
}
impl MIDIPort {
/// The close method.
/// [`MIDIPort.close`](https://developer.mozilla.org/en-US/docs/Web/API/MIDIPort/close)
pub fn close(&self) -> Promise<MIDIPort> {
self.inner.call("close", &[]).as_::<Promise<MIDIPort>>()
}
}