Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XCustomTimeZone.mjs

raw
1 import wasm from "./diplomat-wasm.mjs"
2 import * as diplomatRuntime from "./diplomat-runtime.mjs"
3 import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.mjs"
4
5 const ICU4XCustomTimeZone_box_destroy_registry = new FinalizationRegistry(underlying => {
6 wasm.ICU4XCustomTimeZone_destroy(underlying);
7 });
8
9 export class ICU4XCustomTimeZone {
10 #lifetimeEdges = [];
11 constructor(underlying, owned, edges) {
12 this.underlying = underlying;
13 this.#lifetimeEdges.push(...edges);
14 if (owned) {
15 ICU4XCustomTimeZone_box_destroy_registry.register(this, underlying);
16 }
17 }
18
19 static create_from_string(arg_s) {
20 const buf_arg_s = diplomatRuntime.DiplomatBuf.str8(wasm, arg_s);
21 const diplomat_out = (() => {
22 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
23 wasm.ICU4XCustomTimeZone_create_from_string(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size);
24 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
25 if (is_ok) {
26 const ok_value = new ICU4XCustomTimeZone(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
27 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
28 return ok_value;
29 } else {
30 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
31 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
32 throw new diplomatRuntime.FFIError(throw_value);
33 }
34 })();
35 buf_arg_s.free();
36 return diplomat_out;
37 }
38
39 static create_empty() {
40 return new ICU4XCustomTimeZone(wasm.ICU4XCustomTimeZone_create_empty(), true, []);
41 }
42
43 static create_utc() {
44 return new ICU4XCustomTimeZone(wasm.ICU4XCustomTimeZone_create_utc(), true, []);
45 }
46
47 try_set_gmt_offset_seconds(arg_offset_seconds) {
48 return (() => {
49 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
50 wasm.ICU4XCustomTimeZone_try_set_gmt_offset_seconds(diplomat_receive_buffer, this.underlying, arg_offset_seconds);
51 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
52 if (is_ok) {
53 const ok_value = {};
54 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
55 return ok_value;
56 } else {
57 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
58 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
59 throw new diplomatRuntime.FFIError(throw_value);
60 }
61 })();
62 }
63
64 clear_gmt_offset() {
65 wasm.ICU4XCustomTimeZone_clear_gmt_offset(this.underlying);
66 }
67
68 gmt_offset_seconds() {
69 return (() => {
70 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
71 wasm.ICU4XCustomTimeZone_gmt_offset_seconds(diplomat_receive_buffer, this.underlying);
72 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
73 if (is_ok) {
74 const ok_value = (new Int32Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0];
75 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
76 return ok_value;
77 } else {
78 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
79 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
80 throw new diplomatRuntime.FFIError(throw_value);
81 }
82 })();
83 }
84
85 is_gmt_offset_positive() {
86 return (() => {
87 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
88 wasm.ICU4XCustomTimeZone_is_gmt_offset_positive(diplomat_receive_buffer, this.underlying);
89 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
90 if (is_ok) {
91 const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
92 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
93 return ok_value;
94 } else {
95 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
96 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
97 throw new diplomatRuntime.FFIError(throw_value);
98 }
99 })();
100 }
101
102 is_gmt_offset_zero() {
103 return (() => {
104 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
105 wasm.ICU4XCustomTimeZone_is_gmt_offset_zero(diplomat_receive_buffer, this.underlying);
106 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
107 if (is_ok) {
108 const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
109 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
110 return ok_value;
111 } else {
112 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
113 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
114 throw new diplomatRuntime.FFIError(throw_value);
115 }
116 })();
117 }
118
119 gmt_offset_has_minutes() {
120 return (() => {
121 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
122 wasm.ICU4XCustomTimeZone_gmt_offset_has_minutes(diplomat_receive_buffer, this.underlying);
123 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
124 if (is_ok) {
125 const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
126 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
127 return ok_value;
128 } else {
129 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
130 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
131 throw new diplomatRuntime.FFIError(throw_value);
132 }
133 })();
134 }
135
136 gmt_offset_has_seconds() {
137 return (() => {
138 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
139 wasm.ICU4XCustomTimeZone_gmt_offset_has_seconds(diplomat_receive_buffer, this.underlying);
140 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
141 if (is_ok) {
142 const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
143 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
144 return ok_value;
145 } else {
146 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
147 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
148 throw new diplomatRuntime.FFIError(throw_value);
149 }
150 })();
151 }
152
153 try_set_time_zone_id(arg_id) {
154 const buf_arg_id = diplomatRuntime.DiplomatBuf.str8(wasm, arg_id);
155 const diplomat_out = (() => {
156 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
157 wasm.ICU4XCustomTimeZone_try_set_time_zone_id(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size);
158 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
159 if (is_ok) {
160 const ok_value = {};
161 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
162 return ok_value;
163 } else {
164 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
165 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
166 throw new diplomatRuntime.FFIError(throw_value);
167 }
168 })();
169 buf_arg_id.free();
170 return diplomat_out;
171 }
172
173 try_set_iana_time_zone_id(arg_mapper, arg_id) {
174 const buf_arg_id = diplomatRuntime.DiplomatBuf.str8(wasm, arg_id);
175 const diplomat_out = (() => {
176 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
177 wasm.ICU4XCustomTimeZone_try_set_iana_time_zone_id(diplomat_receive_buffer, this.underlying, arg_mapper.underlying, buf_arg_id.ptr, buf_arg_id.size);
178 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
179 if (is_ok) {
180 const ok_value = {};
181 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
182 return ok_value;
183 } else {
184 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
185 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
186 throw new diplomatRuntime.FFIError(throw_value);
187 }
188 })();
189 buf_arg_id.free();
190 return diplomat_out;
191 }
192
193 try_set_iana_time_zone_id_2(arg_mapper, arg_id) {
194 const buf_arg_id = diplomatRuntime.DiplomatBuf.str8(wasm, arg_id);
195 const diplomat_out = (() => {
196 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
197 wasm.ICU4XCustomTimeZone_try_set_iana_time_zone_id_2(diplomat_receive_buffer, this.underlying, arg_mapper.underlying, buf_arg_id.ptr, buf_arg_id.size);
198 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
199 if (is_ok) {
200 const ok_value = {};
201 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
202 return ok_value;
203 } else {
204 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
205 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
206 throw new diplomatRuntime.FFIError(throw_value);
207 }
208 })();
209 buf_arg_id.free();
210 return diplomat_out;
211 }
212
213 clear_time_zone_id() {
214 wasm.ICU4XCustomTimeZone_clear_time_zone_id(this.underlying);
215 }
216
217 time_zone_id() {
218 return diplomatRuntime.withWriteable(wasm, (writeable) => {
219 return (() => {
220 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
221 wasm.ICU4XCustomTimeZone_time_zone_id(diplomat_receive_buffer, this.underlying, writeable);
222 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
223 if (is_ok) {
224 const ok_value = {};
225 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
226 return ok_value;
227 } else {
228 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
229 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
230 throw new diplomatRuntime.FFIError(throw_value);
231 }
232 })();
233 });
234 }
235
236 try_set_metazone_id(arg_id) {
237 const buf_arg_id = diplomatRuntime.DiplomatBuf.str8(wasm, arg_id);
238 const diplomat_out = (() => {
239 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
240 wasm.ICU4XCustomTimeZone_try_set_metazone_id(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size);
241 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
242 if (is_ok) {
243 const ok_value = {};
244 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
245 return ok_value;
246 } else {
247 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
248 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
249 throw new diplomatRuntime.FFIError(throw_value);
250 }
251 })();
252 buf_arg_id.free();
253 return diplomat_out;
254 }
255
256 clear_metazone_id() {
257 wasm.ICU4XCustomTimeZone_clear_metazone_id(this.underlying);
258 }
259
260 metazone_id() {
261 return diplomatRuntime.withWriteable(wasm, (writeable) => {
262 return (() => {
263 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
264 wasm.ICU4XCustomTimeZone_metazone_id(diplomat_receive_buffer, this.underlying, writeable);
265 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
266 if (is_ok) {
267 const ok_value = {};
268 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
269 return ok_value;
270 } else {
271 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
272 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
273 throw new diplomatRuntime.FFIError(throw_value);
274 }
275 })();
276 });
277 }
278
279 try_set_zone_variant(arg_id) {
280 const buf_arg_id = diplomatRuntime.DiplomatBuf.str8(wasm, arg_id);
281 const diplomat_out = (() => {
282 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
283 wasm.ICU4XCustomTimeZone_try_set_zone_variant(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size);
284 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
285 if (is_ok) {
286 const ok_value = {};
287 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
288 return ok_value;
289 } else {
290 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
291 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
292 throw new diplomatRuntime.FFIError(throw_value);
293 }
294 })();
295 buf_arg_id.free();
296 return diplomat_out;
297 }
298
299 clear_zone_variant() {
300 wasm.ICU4XCustomTimeZone_clear_zone_variant(this.underlying);
301 }
302
303 zone_variant() {
304 return diplomatRuntime.withWriteable(wasm, (writeable) => {
305 return (() => {
306 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
307 wasm.ICU4XCustomTimeZone_zone_variant(diplomat_receive_buffer, this.underlying, writeable);
308 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
309 if (is_ok) {
310 const ok_value = {};
311 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
312 return ok_value;
313 } else {
314 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
315 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
316 throw new diplomatRuntime.FFIError(throw_value);
317 }
318 })();
319 });
320 }
321
322 set_standard_time() {
323 wasm.ICU4XCustomTimeZone_set_standard_time(this.underlying);
324 }
325
326 set_daylight_time() {
327 wasm.ICU4XCustomTimeZone_set_daylight_time(this.underlying);
328 }
329
330 is_standard_time() {
331 return (() => {
332 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
333 wasm.ICU4XCustomTimeZone_is_standard_time(diplomat_receive_buffer, this.underlying);
334 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
335 if (is_ok) {
336 const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
337 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
338 return ok_value;
339 } else {
340 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
341 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
342 throw new diplomatRuntime.FFIError(throw_value);
343 }
344 })();
345 }
346
347 is_daylight_time() {
348 return (() => {
349 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
350 wasm.ICU4XCustomTimeZone_is_daylight_time(diplomat_receive_buffer, this.underlying);
351 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
352 if (is_ok) {
353 const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1;
354 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
355 return ok_value;
356 } else {
357 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
358 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
359 throw new diplomatRuntime.FFIError(throw_value);
360 }
361 })();
362 }
363
364 maybe_calculate_metazone(arg_metazone_calculator, arg_local_datetime) {
365 wasm.ICU4XCustomTimeZone_maybe_calculate_metazone(this.underlying, arg_metazone_calculator.underlying, arg_local_datetime.underlying);
366 }
367 }