Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XTimeZoneFormatter.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 import { ICU4XIsoTimeZoneFormat_js_to_rust, ICU4XIsoTimeZoneFormat_rust_to_js } from "./ICU4XIsoTimeZoneFormat.mjs"
5 import { ICU4XIsoTimeZoneMinuteDisplay_js_to_rust, ICU4XIsoTimeZoneMinuteDisplay_rust_to_js } from "./ICU4XIsoTimeZoneMinuteDisplay.mjs"
6 import { ICU4XIsoTimeZoneSecondDisplay_js_to_rust, ICU4XIsoTimeZoneSecondDisplay_rust_to_js } from "./ICU4XIsoTimeZoneSecondDisplay.mjs"
7
8 const ICU4XTimeZoneFormatter_box_destroy_registry = new FinalizationRegistry(underlying => {
9 wasm.ICU4XTimeZoneFormatter_destroy(underlying);
10 });
11
12 export class ICU4XTimeZoneFormatter {
13 #lifetimeEdges = [];
14 constructor(underlying, owned, edges) {
15 this.underlying = underlying;
16 this.#lifetimeEdges.push(...edges);
17 if (owned) {
18 ICU4XTimeZoneFormatter_box_destroy_registry.register(this, underlying);
19 }
20 }
21
22 static create_with_localized_gmt_fallback(arg_provider, arg_locale) {
23 return (() => {
24 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
25 wasm.ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying);
26 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
27 if (is_ok) {
28 const ok_value = new ICU4XTimeZoneFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
29 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
30 return ok_value;
31 } else {
32 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
33 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
34 throw new diplomatRuntime.FFIError(throw_value);
35 }
36 })();
37 }
38
39 static create_with_iso_8601_fallback(arg_provider, arg_locale, arg_options) {
40 const field_format_arg_options = arg_options["format"];
41 const field_minutes_arg_options = arg_options["minutes"];
42 const field_seconds_arg_options = arg_options["seconds"];
43 return (() => {
44 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
45 wasm.ICU4XTimeZoneFormatter_create_with_iso_8601_fallback(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XIsoTimeZoneFormat_js_to_rust[field_format_arg_options], ICU4XIsoTimeZoneMinuteDisplay_js_to_rust[field_minutes_arg_options], ICU4XIsoTimeZoneSecondDisplay_js_to_rust[field_seconds_arg_options]);
46 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
47 if (is_ok) {
48 const ok_value = new ICU4XTimeZoneFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
49 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
50 return ok_value;
51 } else {
52 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
53 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
54 throw new diplomatRuntime.FFIError(throw_value);
55 }
56 })();
57 }
58
59 load_generic_non_location_long(arg_provider) {
60 return (() => {
61 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
62 wasm.ICU4XTimeZoneFormatter_load_generic_non_location_long(diplomat_receive_buffer, this.underlying, arg_provider.underlying);
63 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
64 if (is_ok) {
65 const ok_value = {};
66 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
67 return ok_value;
68 } else {
69 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
70 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
71 throw new diplomatRuntime.FFIError(throw_value);
72 }
73 })();
74 }
75
76 load_generic_non_location_short(arg_provider) {
77 return (() => {
78 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
79 wasm.ICU4XTimeZoneFormatter_load_generic_non_location_short(diplomat_receive_buffer, this.underlying, arg_provider.underlying);
80 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
81 if (is_ok) {
82 const ok_value = {};
83 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
84 return ok_value;
85 } else {
86 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
87 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
88 throw new diplomatRuntime.FFIError(throw_value);
89 }
90 })();
91 }
92
93 load_specific_non_location_long(arg_provider) {
94 return (() => {
95 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
96 wasm.ICU4XTimeZoneFormatter_load_specific_non_location_long(diplomat_receive_buffer, this.underlying, arg_provider.underlying);
97 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
98 if (is_ok) {
99 const ok_value = {};
100 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
101 return ok_value;
102 } else {
103 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
104 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
105 throw new diplomatRuntime.FFIError(throw_value);
106 }
107 })();
108 }
109
110 load_specific_non_location_short(arg_provider) {
111 return (() => {
112 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
113 wasm.ICU4XTimeZoneFormatter_load_specific_non_location_short(diplomat_receive_buffer, this.underlying, arg_provider.underlying);
114 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
115 if (is_ok) {
116 const ok_value = {};
117 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
118 return ok_value;
119 } else {
120 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
121 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
122 throw new diplomatRuntime.FFIError(throw_value);
123 }
124 })();
125 }
126
127 load_generic_location_format(arg_provider) {
128 return (() => {
129 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
130 wasm.ICU4XTimeZoneFormatter_load_generic_location_format(diplomat_receive_buffer, this.underlying, arg_provider.underlying);
131 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
132 if (is_ok) {
133 const ok_value = {};
134 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
135 return ok_value;
136 } else {
137 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
138 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
139 throw new diplomatRuntime.FFIError(throw_value);
140 }
141 })();
142 }
143
144 include_localized_gmt_format() {
145 return (() => {
146 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
147 wasm.ICU4XTimeZoneFormatter_include_localized_gmt_format(diplomat_receive_buffer, this.underlying);
148 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
149 if (is_ok) {
150 const ok_value = {};
151 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
152 return ok_value;
153 } else {
154 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
155 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
156 throw new diplomatRuntime.FFIError(throw_value);
157 }
158 })();
159 }
160
161 load_iso_8601_format(arg_options) {
162 const field_format_arg_options = arg_options["format"];
163 const field_minutes_arg_options = arg_options["minutes"];
164 const field_seconds_arg_options = arg_options["seconds"];
165 return (() => {
166 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
167 wasm.ICU4XTimeZoneFormatter_load_iso_8601_format(diplomat_receive_buffer, this.underlying, ICU4XIsoTimeZoneFormat_js_to_rust[field_format_arg_options], ICU4XIsoTimeZoneMinuteDisplay_js_to_rust[field_minutes_arg_options], ICU4XIsoTimeZoneSecondDisplay_js_to_rust[field_seconds_arg_options]);
168 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
169 if (is_ok) {
170 const ok_value = {};
171 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
172 return ok_value;
173 } else {
174 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
175 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
176 throw new diplomatRuntime.FFIError(throw_value);
177 }
178 })();
179 }
180
181 format_custom_time_zone(arg_value) {
182 return diplomatRuntime.withWriteable(wasm, (writeable) => {
183 return (() => {
184 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
185 wasm.ICU4XTimeZoneFormatter_format_custom_time_zone(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable);
186 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
187 if (is_ok) {
188 const ok_value = {};
189 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
190 return ok_value;
191 } else {
192 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
193 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
194 throw new diplomatRuntime.FFIError(throw_value);
195 }
196 })();
197 });
198 }
199
200 format_custom_time_zone_no_fallback(arg_value) {
201 return diplomatRuntime.withWriteable(wasm, (writeable) => {
202 return (() => {
203 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
204 wasm.ICU4XTimeZoneFormatter_format_custom_time_zone_no_fallback(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable);
205 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
206 if (is_ok) {
207 const ok_value = {};
208 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
209 return ok_value;
210 } else {
211 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
212 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
213 throw new diplomatRuntime.FFIError(throw_value);
214 }
215 })();
216 });
217 }
218 }