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
164
165
166
167
168
169
use super::*;
/// The MediaKeySession class.
/// [`MediaKeySession`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct MediaKeySession {
inner: EventTarget,
}
impl FromVal for MediaKeySession {
fn from_val(v: &Any) -> Self {
MediaKeySession {
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 MediaKeySession {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for MediaKeySession {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for MediaKeySession {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for MediaKeySession {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<MediaKeySession> for Any {
fn from(s: MediaKeySession) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&MediaKeySession> for Any {
fn from(s: &MediaKeySession) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(MediaKeySession);
impl MediaKeySession {
/// Getter of the `sessionId` attribute.
/// [`MediaKeySession.sessionId`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/sessionId)
pub fn session_id(&self) -> JsString {
self.inner.get("sessionId").as_::<JsString>()
}
}
impl MediaKeySession {
/// Getter of the `expiration` attribute.
/// [`MediaKeySession.expiration`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/expiration)
pub fn expiration(&self) -> f64 {
self.inner.get("expiration").as_::<f64>()
}
}
impl MediaKeySession {
/// Getter of the `closed` attribute.
/// [`MediaKeySession.closed`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/closed)
pub fn closed(&self) -> Promise<MediaKeySessionClosedReason> {
self.inner
.get("closed")
.as_::<Promise<MediaKeySessionClosedReason>>()
}
}
impl MediaKeySession {
/// Getter of the `keyStatuses` attribute.
/// [`MediaKeySession.keyStatuses`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/keyStatuses)
pub fn key_statuses(&self) -> MediaKeyStatusMap {
self.inner.get("keyStatuses").as_::<MediaKeyStatusMap>()
}
}
impl MediaKeySession {
/// Getter of the `onkeystatuseschange` attribute.
/// [`MediaKeySession.onkeystatuseschange`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/onkeystatuseschange)
pub fn onkeystatuseschange(&self) -> Any {
self.inner.get("onkeystatuseschange").as_::<Any>()
}
/// Setter of the `onkeystatuseschange` attribute.
/// [`MediaKeySession.onkeystatuseschange`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/onkeystatuseschange)
pub fn set_onkeystatuseschange(&mut self, value: &Any) {
self.inner.set("onkeystatuseschange", value);
}
}
impl MediaKeySession {
/// Getter of the `onmessage` attribute.
/// [`MediaKeySession.onmessage`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/onmessage)
pub fn onmessage(&self) -> Any {
self.inner.get("onmessage").as_::<Any>()
}
/// Setter of the `onmessage` attribute.
/// [`MediaKeySession.onmessage`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/onmessage)
pub fn set_onmessage(&mut self, value: &Any) {
self.inner.set("onmessage", value);
}
}
impl MediaKeySession {
/// The generateRequest method.
/// [`MediaKeySession.generateRequest`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/generateRequest)
pub fn generate_request(
&self,
init_data_type: &JsString,
init_data: &Any,
) -> Promise<Undefined> {
self.inner
.call(
"generateRequest",
&[init_data_type.into(), init_data.into()],
)
.as_::<Promise<Undefined>>()
}
}
impl MediaKeySession {
/// The load method.
/// [`MediaKeySession.load`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/load)
pub fn load(&self, session_id: &JsString) -> Promise<bool> {
self.inner
.call("load", &[session_id.into()])
.as_::<Promise<bool>>()
}
}
impl MediaKeySession {
/// The update method.
/// [`MediaKeySession.update`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/update)
pub fn update(&self, response: &Any) -> Promise<Undefined> {
self.inner
.call("update", &[response.into()])
.as_::<Promise<Undefined>>()
}
}
impl MediaKeySession {
/// The close method.
/// [`MediaKeySession.close`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/close)
pub fn close(&self) -> Promise<Undefined> {
self.inner.call("close", &[]).as_::<Promise<Undefined>>()
}
}
impl MediaKeySession {
/// The remove method.
/// [`MediaKeySession.remove`](https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySession/remove)
pub fn remove(&self) -> Promise<Undefined> {
self.inner.call("remove", &[]).as_::<Promise<Undefined>>()
}
}