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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
use super::*;
/// The Writer class.
/// [`Writer`](https://developer.mozilla.org/en-US/docs/Web/API/Writer)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Writer {
inner: Any,
}
impl FromVal for Writer {
fn from_val(v: &Any) -> Self {
Writer {
inner: Any::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 Writer {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Writer {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Writer {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Writer {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Writer> for Any {
fn from(s: Writer) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Writer> for Any {
fn from(s: &Writer) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Writer);
impl Writer {
/// Getter of the `sharedContext` attribute.
/// [`Writer.sharedContext`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/sharedContext)
pub fn shared_context(&self) -> JsString {
self.inner.get("sharedContext").as_::<JsString>()
}
}
impl Writer {
/// Getter of the `tone` attribute.
/// [`Writer.tone`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/tone)
pub fn tone(&self) -> WriterTone {
self.inner.get("tone").as_::<WriterTone>()
}
}
impl Writer {
/// Getter of the `format` attribute.
/// [`Writer.format`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/format)
pub fn format(&self) -> WriterFormat {
self.inner.get("format").as_::<WriterFormat>()
}
}
impl Writer {
/// Getter of the `length` attribute.
/// [`Writer.length`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/length)
pub fn length(&self) -> WriterLength {
self.inner.get("length").as_::<WriterLength>()
}
}
impl Writer {
/// Getter of the `expectedInputLanguages` attribute.
/// [`Writer.expectedInputLanguages`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/expectedInputLanguages)
pub fn expected_input_languages(&self) -> TypedArray<JsString> {
self.inner
.get("expectedInputLanguages")
.as_::<TypedArray<JsString>>()
}
}
impl Writer {
/// Getter of the `expectedContextLanguages` attribute.
/// [`Writer.expectedContextLanguages`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/expectedContextLanguages)
pub fn expected_context_languages(&self) -> TypedArray<JsString> {
self.inner
.get("expectedContextLanguages")
.as_::<TypedArray<JsString>>()
}
}
impl Writer {
/// Getter of the `outputLanguage` attribute.
/// [`Writer.outputLanguage`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/outputLanguage)
pub fn output_language(&self) -> JsString {
self.inner.get("outputLanguage").as_::<JsString>()
}
}
impl Writer {
/// Getter of the `inputQuota` attribute.
/// [`Writer.inputQuota`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/inputQuota)
pub fn input_quota(&self) -> f64 {
self.inner.get("inputQuota").as_::<f64>()
}
}
impl Writer {
/// The create method.
/// [`Writer.create`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/create)
pub fn create() -> Promise<Writer> {
Any::global("Writer")
.call("create", &[])
.as_::<Promise<Writer>>()
}
}
impl Writer {
/// The create method.
/// [`Writer.create`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/create)
pub fn create_with_options(options: &WriterCreateOptions) -> Promise<Writer> {
Any::global("Writer")
.call("create", &[options.into()])
.as_::<Promise<Writer>>()
}
}
impl Writer {
/// The availability method.
/// [`Writer.availability`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/availability)
pub fn availability() -> Promise<Availability> {
Any::global("Writer")
.call("availability", &[])
.as_::<Promise<Availability>>()
}
}
impl Writer {
/// The availability method.
/// [`Writer.availability`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/availability)
pub fn availability_with_options(options: &WriterCreateCoreOptions) -> Promise<Availability> {
Any::global("Writer")
.call("availability", &[options.into()])
.as_::<Promise<Availability>>()
}
}
impl Writer {
/// The write method.
/// [`Writer.write`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/write)
pub fn write(&self, input: &JsString) -> Promise<JsString> {
self.inner
.call("write", &[input.into()])
.as_::<Promise<JsString>>()
}
}
impl Writer {
/// The write method.
/// [`Writer.write`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/write)
pub fn write_with_options(
&self,
input: &JsString,
options: &WriterWriteOptions,
) -> Promise<JsString> {
self.inner
.call("write", &[input.into(), options.into()])
.as_::<Promise<JsString>>()
}
}
impl Writer {
/// The writeStreaming method.
/// [`Writer.writeStreaming`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/writeStreaming)
pub fn write_streaming(&self, input: &JsString) -> ReadableStream {
self.inner
.call("writeStreaming", &[input.into()])
.as_::<ReadableStream>()
}
}
impl Writer {
/// The writeStreaming method.
/// [`Writer.writeStreaming`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/writeStreaming)
pub fn write_streaming_with_options(
&self,
input: &JsString,
options: &WriterWriteOptions,
) -> ReadableStream {
self.inner
.call("writeStreaming", &[input.into(), options.into()])
.as_::<ReadableStream>()
}
}
impl Writer {
/// The measureInputUsage method.
/// [`Writer.measureInputUsage`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/measureInputUsage)
pub fn measure_input_usage(&self, input: &JsString) -> Promise<f64> {
self.inner
.call("measureInputUsage", &[input.into()])
.as_::<Promise<f64>>()
}
}
impl Writer {
/// The measureInputUsage method.
/// [`Writer.measureInputUsage`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/measureInputUsage)
pub fn measure_input_usage_with_options(
&self,
input: &JsString,
options: &WriterWriteOptions,
) -> Promise<f64> {
self.inner
.call("measureInputUsage", &[input.into(), options.into()])
.as_::<Promise<f64>>()
}
}
impl Writer {
/// The destroy method.
/// [`Writer.destroy`](https://developer.mozilla.org/en-US/docs/Web/API/Writer/destroy)
pub fn destroy(&self) -> Undefined {
self.inner.call("destroy", &[]).as_::<Undefined>()
}
}