Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XTimeZoneIdMapper.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 ICU4XTimeZoneIdMapper_box_destroy_registry = new FinalizationRegistry(underlying => {
6 wasm.ICU4XTimeZoneIdMapper_destroy(underlying);
7 });
8
9 export class ICU4XTimeZoneIdMapper {
10 #lifetimeEdges = [];
11 constructor(underlying, owned, edges) {
12 this.underlying = underlying;
13 this.#lifetimeEdges.push(...edges);
14 if (owned) {
15 ICU4XTimeZoneIdMapper_box_destroy_registry.register(this, underlying);
16 }
17 }
18
19 static create(arg_provider) {
20 return (() => {
21 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
22 wasm.ICU4XTimeZoneIdMapper_create(diplomat_receive_buffer, arg_provider.underlying);
23 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
24 if (is_ok) {
25 const ok_value = new ICU4XTimeZoneIdMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
26 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
27 return ok_value;
28 } else {
29 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
30 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
31 throw new diplomatRuntime.FFIError(throw_value);
32 }
33 })();
34 }
35
36 iana_to_bcp47(arg_value) {
37 const buf_arg_value = diplomatRuntime.DiplomatBuf.str8(wasm, arg_value);
38 const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => {
39 return (() => {
40 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
41 wasm.ICU4XTimeZoneIdMapper_iana_to_bcp47(diplomat_receive_buffer, this.underlying, buf_arg_value.ptr, buf_arg_value.size, writeable);
42 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
43 if (is_ok) {
44 const ok_value = {};
45 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
46 return ok_value;
47 } else {
48 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
49 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
50 throw new diplomatRuntime.FFIError(throw_value);
51 }
52 })();
53 });
54 buf_arg_value.free();
55 return diplomat_out;
56 }
57
58 normalize_iana(arg_value) {
59 const buf_arg_value = diplomatRuntime.DiplomatBuf.str8(wasm, arg_value);
60 const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => {
61 return (() => {
62 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
63 wasm.ICU4XTimeZoneIdMapper_normalize_iana(diplomat_receive_buffer, this.underlying, buf_arg_value.ptr, buf_arg_value.size, writeable);
64 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
65 if (is_ok) {
66 const ok_value = {};
67 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
68 return ok_value;
69 } else {
70 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
71 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
72 throw new diplomatRuntime.FFIError(throw_value);
73 }
74 })();
75 });
76 buf_arg_value.free();
77 return diplomat_out;
78 }
79
80 canonicalize_iana(arg_value) {
81 const buf_arg_value = diplomatRuntime.DiplomatBuf.str8(wasm, arg_value);
82 const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => {
83 return (() => {
84 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
85 wasm.ICU4XTimeZoneIdMapper_canonicalize_iana(diplomat_receive_buffer, this.underlying, buf_arg_value.ptr, buf_arg_value.size, writeable);
86 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
87 if (is_ok) {
88 const ok_value = {};
89 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
90 return ok_value;
91 } else {
92 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
93 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
94 throw new diplomatRuntime.FFIError(throw_value);
95 }
96 })();
97 });
98 buf_arg_value.free();
99 return diplomat_out;
100 }
101
102 find_canonical_iana_from_bcp47(arg_value) {
103 const buf_arg_value = diplomatRuntime.DiplomatBuf.str8(wasm, arg_value);
104 const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => {
105 return (() => {
106 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
107 wasm.ICU4XTimeZoneIdMapper_find_canonical_iana_from_bcp47(diplomat_receive_buffer, this.underlying, buf_arg_value.ptr, buf_arg_value.size, writeable);
108 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
109 if (is_ok) {
110 const ok_value = {};
111 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
112 return ok_value;
113 } else {
114 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
115 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
116 throw new diplomatRuntime.FFIError(throw_value);
117 }
118 })();
119 });
120 buf_arg_value.free();
121 return diplomat_out;
122 }
123 }