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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
use super::*;
/// The HIDDevice class.
/// [`HIDDevice`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct HIDDevice {
inner: EventTarget,
}
impl FromVal for HIDDevice {
fn from_val(v: &Any) -> Self {
HIDDevice {
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 HIDDevice {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for HIDDevice {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for HIDDevice {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for HIDDevice {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<HIDDevice> for Any {
fn from(s: HIDDevice) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&HIDDevice> for Any {
fn from(s: &HIDDevice) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(HIDDevice);
impl HIDDevice {
/// Getter of the `oninputreport` attribute.
/// [`HIDDevice.oninputreport`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/oninputreport)
pub fn oninputreport(&self) -> Any {
self.inner.get("oninputreport").as_::<Any>()
}
/// Setter of the `oninputreport` attribute.
/// [`HIDDevice.oninputreport`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/oninputreport)
pub fn set_oninputreport(&mut self, value: &Any) {
self.inner.set("oninputreport", value);
}
}
impl HIDDevice {
/// Getter of the `opened` attribute.
/// [`HIDDevice.opened`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/opened)
pub fn opened(&self) -> bool {
self.inner.get("opened").as_::<bool>()
}
}
impl HIDDevice {
/// Getter of the `vendorId` attribute.
/// [`HIDDevice.vendorId`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/vendorId)
pub fn vendor_id(&self) -> u16 {
self.inner.get("vendorId").as_::<u16>()
}
}
impl HIDDevice {
/// Getter of the `productId` attribute.
/// [`HIDDevice.productId`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/productId)
pub fn product_id(&self) -> u16 {
self.inner.get("productId").as_::<u16>()
}
}
impl HIDDevice {
/// Getter of the `productName` attribute.
/// [`HIDDevice.productName`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/productName)
pub fn product_name(&self) -> JsString {
self.inner.get("productName").as_::<JsString>()
}
}
impl HIDDevice {
/// Getter of the `collections` attribute.
/// [`HIDDevice.collections`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/collections)
pub fn collections(&self) -> TypedArray<HIDCollectionInfo> {
self.inner
.get("collections")
.as_::<TypedArray<HIDCollectionInfo>>()
}
}
impl HIDDevice {
/// The open method.
/// [`HIDDevice.open`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/open)
pub fn open(&self) -> Promise<Undefined> {
self.inner.call("open", &[]).as_::<Promise<Undefined>>()
}
}
impl HIDDevice {
/// The close method.
/// [`HIDDevice.close`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/close)
pub fn close(&self) -> Promise<Undefined> {
self.inner.call("close", &[]).as_::<Promise<Undefined>>()
}
}
impl HIDDevice {
/// The forget method.
/// [`HIDDevice.forget`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/forget)
pub fn forget(&self) -> Promise<Undefined> {
self.inner.call("forget", &[]).as_::<Promise<Undefined>>()
}
}
impl HIDDevice {
/// The sendReport method.
/// [`HIDDevice.sendReport`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/sendReport)
pub fn send_report(&self, report_id: u8, data: &Any) -> Promise<Undefined> {
self.inner
.call("sendReport", &[report_id.into(), data.into()])
.as_::<Promise<Undefined>>()
}
}
impl HIDDevice {
/// The sendFeatureReport method.
/// [`HIDDevice.sendFeatureReport`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/sendFeatureReport)
pub fn send_feature_report(&self, report_id: u8, data: &Any) -> Promise<Undefined> {
self.inner
.call("sendFeatureReport", &[report_id.into(), data.into()])
.as_::<Promise<Undefined>>()
}
}
impl HIDDevice {
/// The receiveFeatureReport method.
/// [`HIDDevice.receiveFeatureReport`](https://developer.mozilla.org/en-US/docs/Web/API/HIDDevice/receiveFeatureReport)
pub fn receive_feature_report(&self, report_id: u8) -> Promise<DataView> {
self.inner
.call("receiveFeatureReport", &[report_id.into()])
.as_::<Promise<DataView>>()
}
}