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
use super::*;
/// The AudioDecoder class.
/// [`AudioDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct AudioDecoder {
inner: EventTarget,
}
impl FromVal for AudioDecoder {
fn from_val(v: &Any) -> Self {
AudioDecoder {
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 AudioDecoder {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for AudioDecoder {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for AudioDecoder {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for AudioDecoder {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<AudioDecoder> for Any {
fn from(s: AudioDecoder) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&AudioDecoder> for Any {
fn from(s: &AudioDecoder) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(AudioDecoder);
impl AudioDecoder {
/// Getter of the `state` attribute.
/// [`AudioDecoder.state`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/state)
pub fn state(&self) -> CodecState {
self.inner.get("state").as_::<CodecState>()
}
}
impl AudioDecoder {
/// Getter of the `decodeQueueSize` attribute.
/// [`AudioDecoder.decodeQueueSize`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/decodeQueueSize)
pub fn decode_queue_size(&self) -> u32 {
self.inner.get("decodeQueueSize").as_::<u32>()
}
}
impl AudioDecoder {
/// Getter of the `ondequeue` attribute.
/// [`AudioDecoder.ondequeue`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/ondequeue)
pub fn ondequeue(&self) -> Any {
self.inner.get("ondequeue").as_::<Any>()
}
/// Setter of the `ondequeue` attribute.
/// [`AudioDecoder.ondequeue`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/ondequeue)
pub fn set_ondequeue(&mut self, value: &Any) {
self.inner.set("ondequeue", value);
}
}
impl AudioDecoder {
/// The `new AudioDecoder(..)` constructor, creating a new AudioDecoder instance
pub fn new(init: &AudioDecoderInit) -> AudioDecoder {
Self {
inner: Any::global("AudioDecoder")
.new(&[init.into()])
.as_::<EventTarget>(),
}
}
}
impl AudioDecoder {
/// The configure method.
/// [`AudioDecoder.configure`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/configure)
pub fn configure(&self, config: &AudioDecoderConfig) -> Undefined {
self.inner
.call("configure", &[config.into()])
.as_::<Undefined>()
}
}
impl AudioDecoder {
/// The decode method.
/// [`AudioDecoder.decode`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/decode)
pub fn decode(&self, chunk: &EncodedAudioChunk) -> Undefined {
self.inner
.call("decode", &[chunk.into()])
.as_::<Undefined>()
}
}
impl AudioDecoder {
/// The flush method.
/// [`AudioDecoder.flush`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/flush)
pub fn flush(&self) -> Promise<Undefined> {
self.inner.call("flush", &[]).as_::<Promise<Undefined>>()
}
}
impl AudioDecoder {
/// The reset method.
/// [`AudioDecoder.reset`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/reset)
pub fn reset(&self) -> Undefined {
self.inner.call("reset", &[]).as_::<Undefined>()
}
}
impl AudioDecoder {
/// The close method.
/// [`AudioDecoder.close`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/close)
pub fn close(&self) -> Undefined {
self.inner.call("close", &[]).as_::<Undefined>()
}
}
impl AudioDecoder {
/// The isConfigSupported method.
/// [`AudioDecoder.isConfigSupported`](https://developer.mozilla.org/en-US/docs/Web/API/AudioDecoder/isConfigSupported)
pub fn is_config_supported(config: &AudioDecoderConfig) -> Promise<AudioDecoderSupport> {
Any::global("AudioDecoder")
.call("isConfigSupported", &[config.into()])
.as_::<Promise<AudioDecoderSupport>>()
}
}