Skip to main content

web_sys/features/
gen_AudioDataInit.rs

1#![allow(unused_imports)]
2#![allow(clippy::all)]
3use super::*;
4use wasm_bindgen::prelude::*;
5#[cfg(web_sys_unstable_apis)]
6#[wasm_bindgen]
7extern "C" {
8    # [wasm_bindgen (extends = :: js_sys :: Object , js_name = AudioDataInit)]
9    #[derive(Debug, Clone, PartialEq, Eq)]
10    #[doc = "The `AudioDataInit` dictionary."]
11    #[doc = ""]
12    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
13    #[doc = ""]
14    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
15    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
16    pub type AudioDataInit;
17    #[cfg(web_sys_unstable_apis)]
18    #[doc = "Get the `data` field of this object."]
19    #[doc = ""]
20    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
21    #[doc = ""]
22    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
23    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
24    #[wasm_bindgen(method, getter = "data")]
25    pub fn get_data(this: &AudioDataInit) -> ::js_sys::Object;
26    #[cfg(web_sys_unstable_apis)]
27    #[doc = "Change the `data` field of this object."]
28    #[doc = ""]
29    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
30    #[doc = ""]
31    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
32    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
33    #[wasm_bindgen(method, setter = "data")]
34    pub fn set_data(this: &AudioDataInit, val: &::js_sys::Object);
35    #[cfg(web_sys_unstable_apis)]
36    #[doc = "Change the `data` field of this object."]
37    #[doc = ""]
38    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
39    #[doc = ""]
40    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
41    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
42    #[doc = "# Safety"]
43    #[doc = ""]
44    #[doc = "The `val` slice must outlive any use of the dictionary on the JavaScript side. wasm-bindgen passes a raw view into wasm linear memory — if the underlying data is freed or moved before JS is done reading the field, the behaviour is undefined. Prefer the `_array` variant (takes `&Uint8Array`) for a safe alternative that copies the data."]
45    #[wasm_bindgen(method, setter = "data")]
46    pub unsafe fn set_data_u8_slice(this: &AudioDataInit, val: &mut [u8]);
47    #[cfg(web_sys_unstable_apis)]
48    #[doc = "Change the `data` field of this object."]
49    #[doc = ""]
50    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
51    #[doc = ""]
52    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
53    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
54    #[wasm_bindgen(method, setter = "data")]
55    pub fn set_data_u8_array(this: &AudioDataInit, val: &::js_sys::Uint8Array);
56    #[cfg(web_sys_unstable_apis)]
57    #[cfg(feature = "AudioSampleFormat")]
58    #[doc = "Get the `format` field of this object."]
59    #[doc = ""]
60    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`, `AudioSampleFormat`*"]
61    #[doc = ""]
62    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
63    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
64    #[wasm_bindgen(method, getter = "format")]
65    pub fn get_format(this: &AudioDataInit) -> AudioSampleFormat;
66    #[cfg(web_sys_unstable_apis)]
67    #[cfg(feature = "AudioSampleFormat")]
68    #[doc = "Change the `format` field of this object."]
69    #[doc = ""]
70    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`, `AudioSampleFormat`*"]
71    #[doc = ""]
72    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
73    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
74    #[wasm_bindgen(method, setter = "format")]
75    pub fn set_format(this: &AudioDataInit, val: AudioSampleFormat);
76    #[cfg(web_sys_unstable_apis)]
77    #[doc = "Get the `numberOfChannels` field of this object."]
78    #[doc = ""]
79    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
80    #[doc = ""]
81    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
82    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
83    #[wasm_bindgen(method, getter = "numberOfChannels")]
84    pub fn get_number_of_channels(this: &AudioDataInit) -> u32;
85    #[cfg(web_sys_unstable_apis)]
86    #[doc = "Change the `numberOfChannels` field of this object."]
87    #[doc = ""]
88    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
89    #[doc = ""]
90    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
91    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
92    #[wasm_bindgen(method, setter = "numberOfChannels")]
93    pub fn set_number_of_channels(this: &AudioDataInit, val: u32);
94    #[cfg(web_sys_unstable_apis)]
95    #[doc = "Get the `numberOfFrames` field of this object."]
96    #[doc = ""]
97    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
98    #[doc = ""]
99    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
100    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
101    #[wasm_bindgen(method, getter = "numberOfFrames")]
102    pub fn get_number_of_frames(this: &AudioDataInit) -> u32;
103    #[cfg(web_sys_unstable_apis)]
104    #[doc = "Change the `numberOfFrames` field of this object."]
105    #[doc = ""]
106    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
107    #[doc = ""]
108    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
109    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
110    #[wasm_bindgen(method, setter = "numberOfFrames")]
111    pub fn set_number_of_frames(this: &AudioDataInit, val: u32);
112    #[cfg(web_sys_unstable_apis)]
113    #[doc = "Get the `sampleRate` field of this object."]
114    #[doc = ""]
115    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
116    #[doc = ""]
117    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
118    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
119    #[wasm_bindgen(method, getter = "sampleRate")]
120    pub fn get_sample_rate(this: &AudioDataInit) -> f32;
121    #[cfg(web_sys_unstable_apis)]
122    #[doc = "Change the `sampleRate` field of this object."]
123    #[doc = ""]
124    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
125    #[doc = ""]
126    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
127    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
128    #[wasm_bindgen(method, setter = "sampleRate")]
129    pub fn set_sample_rate(this: &AudioDataInit, val: f32);
130    #[cfg(web_sys_unstable_apis)]
131    #[doc = "Get the `timestamp` field of this object."]
132    #[doc = ""]
133    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
134    #[doc = ""]
135    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
136    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
137    #[wasm_bindgen(method, getter = "timestamp")]
138    pub fn get_timestamp(this: &AudioDataInit) -> f64;
139    #[cfg(web_sys_unstable_apis)]
140    #[doc = "Change the `timestamp` field of this object."]
141    #[doc = ""]
142    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
143    #[doc = ""]
144    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
145    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
146    #[wasm_bindgen(method, setter = "timestamp")]
147    pub fn set_timestamp(this: &AudioDataInit, val: i32);
148    #[cfg(web_sys_unstable_apis)]
149    #[doc = "Change the `timestamp` field of this object."]
150    #[doc = ""]
151    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
152    #[doc = ""]
153    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
154    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
155    #[wasm_bindgen(method, setter = "timestamp")]
156    pub fn set_timestamp_f64(this: &AudioDataInit, val: f64);
157    #[cfg(web_sys_unstable_apis)]
158    #[doc = "Get the `transfer` field of this object."]
159    #[doc = ""]
160    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
161    #[doc = ""]
162    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
163    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
164    #[wasm_bindgen(method, getter = "transfer")]
165    pub fn get_transfer(this: &AudioDataInit) -> Option<::js_sys::Array<::js_sys::ArrayBuffer>>;
166    #[cfg(web_sys_unstable_apis)]
167    #[doc = "Change the `transfer` field of this object."]
168    #[doc = ""]
169    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`*"]
170    #[doc = ""]
171    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
172    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
173    #[wasm_bindgen(method, setter = "transfer")]
174    pub fn set_transfer(this: &AudioDataInit, val: &[::js_sys::ArrayBuffer]);
175}
176#[cfg(web_sys_unstable_apis)]
177impl AudioDataInit {
178    #[cfg(feature = "AudioSampleFormat")]
179    #[doc = "Construct a new `AudioDataInit`."]
180    #[doc = ""]
181    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`, `AudioSampleFormat`*"]
182    #[doc = ""]
183    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
184    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
185    pub fn new(
186        data: &::js_sys::Object,
187        format: AudioSampleFormat,
188        number_of_channels: u32,
189        number_of_frames: u32,
190        sample_rate: f32,
191        timestamp: i32,
192    ) -> Self {
193        #[allow(unused_mut)]
194        let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
195        ret.set_data(data);
196        ret.set_format(format);
197        ret.set_number_of_channels(number_of_channels);
198        ret.set_number_of_frames(number_of_frames);
199        ret.set_sample_rate(sample_rate);
200        ret.set_timestamp(timestamp);
201        ret
202    }
203    #[cfg(feature = "AudioSampleFormat")]
204    #[doc = "Construct a new `AudioDataInit`."]
205    #[doc = ""]
206    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`, `AudioSampleFormat`*"]
207    #[doc = ""]
208    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
209    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
210    pub unsafe fn new_with_u8_slice(
211        data: &mut [u8],
212        format: AudioSampleFormat,
213        number_of_channels: u32,
214        number_of_frames: u32,
215        sample_rate: f32,
216        timestamp: i32,
217    ) -> Self {
218        #[allow(unused_mut)]
219        let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
220        ret.set_data_u8_slice(data);
221        ret.set_format(format);
222        ret.set_number_of_channels(number_of_channels);
223        ret.set_number_of_frames(number_of_frames);
224        ret.set_sample_rate(sample_rate);
225        ret.set_timestamp(timestamp);
226        ret
227    }
228    #[cfg(feature = "AudioSampleFormat")]
229    #[doc = "Construct a new `AudioDataInit`."]
230    #[doc = ""]
231    #[doc = "*This API requires the following crate features to be activated: `AudioDataInit`, `AudioSampleFormat`*"]
232    #[doc = ""]
233    #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
234    #[doc = "[described in the `wasm-bindgen` guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/unstable-apis.html)*"]
235    pub fn new_with_u8_array(
236        data: &::js_sys::Uint8Array,
237        format: AudioSampleFormat,
238        number_of_channels: u32,
239        number_of_frames: u32,
240        sample_rate: f32,
241        timestamp: i32,
242    ) -> Self {
243        #[allow(unused_mut)]
244        let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
245        ret.set_data_u8_array(data);
246        ret.set_format(format);
247        ret.set_number_of_channels(number_of_channels);
248        ret.set_number_of_frames(number_of_frames);
249        ret.set_sample_rate(sample_rate);
250        ret.set_timestamp(timestamp);
251        ret
252    }
253    #[cfg(web_sys_unstable_apis)]
254    #[deprecated = "Use `set_data()` instead."]
255    pub fn data(&mut self, val: &::js_sys::Object) -> &mut Self {
256        self.set_data(val);
257        self
258    }
259    #[cfg(web_sys_unstable_apis)]
260    #[cfg(feature = "AudioSampleFormat")]
261    #[deprecated = "Use `set_format()` instead."]
262    pub fn format(&mut self, val: AudioSampleFormat) -> &mut Self {
263        self.set_format(val);
264        self
265    }
266    #[cfg(web_sys_unstable_apis)]
267    #[deprecated = "Use `set_number_of_channels()` instead."]
268    pub fn number_of_channels(&mut self, val: u32) -> &mut Self {
269        self.set_number_of_channels(val);
270        self
271    }
272    #[cfg(web_sys_unstable_apis)]
273    #[deprecated = "Use `set_number_of_frames()` instead."]
274    pub fn number_of_frames(&mut self, val: u32) -> &mut Self {
275        self.set_number_of_frames(val);
276        self
277    }
278    #[cfg(web_sys_unstable_apis)]
279    #[deprecated = "Use `set_sample_rate()` instead."]
280    pub fn sample_rate(&mut self, val: f32) -> &mut Self {
281        self.set_sample_rate(val);
282        self
283    }
284    #[cfg(web_sys_unstable_apis)]
285    #[deprecated = "Use `set_timestamp()` instead."]
286    pub fn timestamp(&mut self, val: i32) -> &mut Self {
287        self.set_timestamp(val);
288        self
289    }
290    #[cfg(web_sys_unstable_apis)]
291    #[deprecated = "Use `set_transfer()` instead."]
292    pub fn transfer(&mut self, val: &[::js_sys::ArrayBuffer]) -> &mut Self {
293        self.set_transfer(val);
294        self
295    }
296}