icu_capi/
date_time_formatter.rs

1// This file is part of ICU4X. For terms of use, please see the file
2// called LICENSE at the top level of the ICU4X source tree
3// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5// @generated by tools/make/codegen/src/capi_datetime.rs
6
7#[rustfmt::skip]
8#[diplomat::bridge]
9#[diplomat::abi_rename = "icu4x_{0}_mv1"]
10#[diplomat::attr(auto, namespace = "icu4x")]
11pub mod ffi {
12    use alloc::boxed::Box;
13    use icu_calendar::Gregorian;
14    use writeable::Writeable;
15
16    #[allow(unused_imports)]
17    use crate::{
18        date::ffi::{Date, IsoDate},
19        datetime::ffi::DateTime,
20        datetime_helpers::map_or_default,
21        datetime_options::ffi::{DateTimeAlignment, DateTimeLength, TimePrecision, YearStyle},
22        errors::ffi::DateTimeFormatterLoadError,
23        errors::ffi::DateTimeMismatchedCalendarError,
24        locale_core::ffi::Locale,
25        time::ffi::Time,
26    };
27
28    #[cfg(feature = "buffer_provider")]
29    use crate::provider::ffi::DataProvider;
30
31    #[diplomat::opaque]
32    #[diplomat::rust_link(icu::datetime::DateTimeFormatter, Typedef)]
33    pub struct DateTimeFormatter(
34        pub  icu_datetime::DateTimeFormatter<
35            icu_datetime::fieldsets::enums::CompositeDateTimeFieldSet,
36        >,
37    );
38
39    impl DateTimeFormatter {
40        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "dt")]
41        #[diplomat::rust_link(icu::datetime::fieldsets::DT, Struct)]
42        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_time_precision, FnInStruct, compact)]
43        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_alignment, FnInStruct, compact)]
44        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_length, FnInStruct, compact)]
45        #[diplomat::rust_link(icu::datetime::fieldsets::DT::short, FnInStruct, hidden)]
46        #[diplomat::rust_link(icu::datetime::fieldsets::DT::medium, FnInStruct, hidden)]
47        #[diplomat::rust_link(icu::datetime::fieldsets::DT::long, FnInStruct, hidden)]
48        #[cfg(feature = "compiled_data")]
49        pub fn create_dt(
50            locale: &Locale,
51            length: Option<DateTimeLength>,
52            time_precision: Option<TimePrecision>,
53            alignment: Option<DateTimeAlignment>,
54        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
55            let prefs = (&locale.0).into();
56            let mut options = icu_datetime::fieldsets::DT::with_length(map_or_default(length));
57            options.time_precision = time_precision.map(Into::into);
58            options.alignment = alignment.map(Into::into);
59            Ok(Box::new(Self(
60                icu_datetime
61                    ::DateTimeFormatter
62                    ::try_new(
63                        prefs,
64                        options
65                    )?
66                .cast_into_fset(),
67            )))
68        }
69        
70        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "dt_with_provider")]
71        #[diplomat::rust_link(icu::datetime::fieldsets::DT, Struct)]
72        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_time_precision, FnInStruct, compact)]
73        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_alignment, FnInStruct, compact)]
74        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_length, FnInStruct, compact)]
75        #[diplomat::rust_link(icu::datetime::fieldsets::DT::short, FnInStruct, hidden)]
76        #[diplomat::rust_link(icu::datetime::fieldsets::DT::medium, FnInStruct, hidden)]
77        #[diplomat::rust_link(icu::datetime::fieldsets::DT::long, FnInStruct, hidden)]
78        #[cfg(feature = "buffer_provider")]
79        pub fn create_dt_with_provider(
80            provider: &DataProvider,
81            locale: &Locale,
82            length: Option<DateTimeLength>,
83            time_precision: Option<TimePrecision>,
84            alignment: Option<DateTimeAlignment>,
85        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
86            let prefs = (&locale.0).into();
87            let mut options = icu_datetime::fieldsets::DT::with_length(map_or_default(length));
88            options.time_precision = time_precision.map(Into::into);
89            options.alignment = alignment.map(Into::into);
90            Ok(Box::new(Self(
91                icu_datetime
92                    ::DateTimeFormatter
93                    ::try_new_with_buffer_provider(
94                        provider.get()?,
95                        prefs,
96                        options
97                    )?
98                .cast_into_fset(),
99            )))
100        }
101        
102        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdt")]
103        #[diplomat::rust_link(icu::datetime::fieldsets::MDT, Struct)]
104        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_time_precision, FnInStruct, compact)]
105        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_alignment, FnInStruct, compact)]
106        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_length, FnInStruct, compact)]
107        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::short, FnInStruct, hidden)]
108        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::medium, FnInStruct, hidden)]
109        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::long, FnInStruct, hidden)]
110        #[cfg(feature = "compiled_data")]
111        pub fn create_mdt(
112            locale: &Locale,
113            length: Option<DateTimeLength>,
114            time_precision: Option<TimePrecision>,
115            alignment: Option<DateTimeAlignment>,
116        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
117            let prefs = (&locale.0).into();
118            let mut options = icu_datetime::fieldsets::MDT::with_length(map_or_default(length));
119            options.time_precision = time_precision.map(Into::into);
120            options.alignment = alignment.map(Into::into);
121            Ok(Box::new(Self(
122                icu_datetime
123                    ::DateTimeFormatter
124                    ::try_new(
125                        prefs,
126                        options
127                    )?
128                .cast_into_fset(),
129            )))
130        }
131        
132        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdt_with_provider")]
133        #[diplomat::rust_link(icu::datetime::fieldsets::MDT, Struct)]
134        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_time_precision, FnInStruct, compact)]
135        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_alignment, FnInStruct, compact)]
136        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_length, FnInStruct, compact)]
137        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::short, FnInStruct, hidden)]
138        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::medium, FnInStruct, hidden)]
139        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::long, FnInStruct, hidden)]
140        #[cfg(feature = "buffer_provider")]
141        pub fn create_mdt_with_provider(
142            provider: &DataProvider,
143            locale: &Locale,
144            length: Option<DateTimeLength>,
145            time_precision: Option<TimePrecision>,
146            alignment: Option<DateTimeAlignment>,
147        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
148            let prefs = (&locale.0).into();
149            let mut options = icu_datetime::fieldsets::MDT::with_length(map_or_default(length));
150            options.time_precision = time_precision.map(Into::into);
151            options.alignment = alignment.map(Into::into);
152            Ok(Box::new(Self(
153                icu_datetime
154                    ::DateTimeFormatter
155                    ::try_new_with_buffer_provider(
156                        provider.get()?,
157                        prefs,
158                        options
159                    )?
160                .cast_into_fset(),
161            )))
162        }
163        
164        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdt")]
165        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT, Struct)]
166        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_time_precision, FnInStruct, compact)]
167        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_alignment, FnInStruct, compact)]
168        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_year_style, FnInStruct, compact)]
169        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_length, FnInStruct, compact)]
170        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::short, FnInStruct, hidden)]
171        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::medium, FnInStruct, hidden)]
172        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::long, FnInStruct, hidden)]
173        #[diplomat::demo(default_constructor)]
174        #[cfg(feature = "compiled_data")]
175        pub fn create_ymdt(
176            locale: &Locale,
177            length: Option<DateTimeLength>,
178            time_precision: Option<TimePrecision>,
179            alignment: Option<DateTimeAlignment>,
180            year_style: Option<YearStyle>,
181        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
182            let prefs = (&locale.0).into();
183            let mut options = icu_datetime::fieldsets::YMDT::with_length(map_or_default(length));
184            options.time_precision = time_precision.map(Into::into);
185            options.alignment = alignment.map(Into::into);
186            options.year_style = year_style.map(Into::into);
187            Ok(Box::new(Self(
188                icu_datetime
189                    ::DateTimeFormatter
190                    ::try_new(
191                        prefs,
192                        options
193                    )?
194                .cast_into_fset(),
195            )))
196        }
197        
198        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdt_with_provider")]
199        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT, Struct)]
200        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_time_precision, FnInStruct, compact)]
201        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_alignment, FnInStruct, compact)]
202        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_year_style, FnInStruct, compact)]
203        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_length, FnInStruct, compact)]
204        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::short, FnInStruct, hidden)]
205        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::medium, FnInStruct, hidden)]
206        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::long, FnInStruct, hidden)]
207        #[cfg(feature = "buffer_provider")]
208        pub fn create_ymdt_with_provider(
209            provider: &DataProvider,
210            locale: &Locale,
211            length: Option<DateTimeLength>,
212            time_precision: Option<TimePrecision>,
213            alignment: Option<DateTimeAlignment>,
214            year_style: Option<YearStyle>,
215        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
216            let prefs = (&locale.0).into();
217            let mut options = icu_datetime::fieldsets::YMDT::with_length(map_or_default(length));
218            options.time_precision = time_precision.map(Into::into);
219            options.alignment = alignment.map(Into::into);
220            options.year_style = year_style.map(Into::into);
221            Ok(Box::new(Self(
222                icu_datetime
223                    ::DateTimeFormatter
224                    ::try_new_with_buffer_provider(
225                        provider.get()?,
226                        prefs,
227                        options
228                    )?
229                .cast_into_fset(),
230            )))
231        }
232        
233        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "det")]
234        #[diplomat::rust_link(icu::datetime::fieldsets::DET, Struct)]
235        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_time_precision, FnInStruct, compact)]
236        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_alignment, FnInStruct, compact)]
237        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_length, FnInStruct, compact)]
238        #[diplomat::rust_link(icu::datetime::fieldsets::DET::short, FnInStruct, hidden)]
239        #[diplomat::rust_link(icu::datetime::fieldsets::DET::medium, FnInStruct, hidden)]
240        #[diplomat::rust_link(icu::datetime::fieldsets::DET::long, FnInStruct, hidden)]
241        #[cfg(feature = "compiled_data")]
242        pub fn create_det(
243            locale: &Locale,
244            length: Option<DateTimeLength>,
245            time_precision: Option<TimePrecision>,
246            alignment: Option<DateTimeAlignment>,
247        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
248            let prefs = (&locale.0).into();
249            let mut options = icu_datetime::fieldsets::DET::with_length(map_or_default(length));
250            options.time_precision = time_precision.map(Into::into);
251            options.alignment = alignment.map(Into::into);
252            Ok(Box::new(Self(
253                icu_datetime
254                    ::DateTimeFormatter
255                    ::try_new(
256                        prefs,
257                        options
258                    )?
259                .cast_into_fset(),
260            )))
261        }
262        
263        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "det_with_provider")]
264        #[diplomat::rust_link(icu::datetime::fieldsets::DET, Struct)]
265        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_time_precision, FnInStruct, compact)]
266        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_alignment, FnInStruct, compact)]
267        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_length, FnInStruct, compact)]
268        #[diplomat::rust_link(icu::datetime::fieldsets::DET::short, FnInStruct, hidden)]
269        #[diplomat::rust_link(icu::datetime::fieldsets::DET::medium, FnInStruct, hidden)]
270        #[diplomat::rust_link(icu::datetime::fieldsets::DET::long, FnInStruct, hidden)]
271        #[cfg(feature = "buffer_provider")]
272        pub fn create_det_with_provider(
273            provider: &DataProvider,
274            locale: &Locale,
275            length: Option<DateTimeLength>,
276            time_precision: Option<TimePrecision>,
277            alignment: Option<DateTimeAlignment>,
278        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
279            let prefs = (&locale.0).into();
280            let mut options = icu_datetime::fieldsets::DET::with_length(map_or_default(length));
281            options.time_precision = time_precision.map(Into::into);
282            options.alignment = alignment.map(Into::into);
283            Ok(Box::new(Self(
284                icu_datetime
285                    ::DateTimeFormatter
286                    ::try_new_with_buffer_provider(
287                        provider.get()?,
288                        prefs,
289                        options
290                    )?
291                .cast_into_fset(),
292            )))
293        }
294        
295        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdet")]
296        #[diplomat::rust_link(icu::datetime::fieldsets::MDET, Struct)]
297        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_time_precision, FnInStruct, compact)]
298        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_alignment, FnInStruct, compact)]
299        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_length, FnInStruct, compact)]
300        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::short, FnInStruct, hidden)]
301        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::medium, FnInStruct, hidden)]
302        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::long, FnInStruct, hidden)]
303        #[cfg(feature = "compiled_data")]
304        pub fn create_mdet(
305            locale: &Locale,
306            length: Option<DateTimeLength>,
307            time_precision: Option<TimePrecision>,
308            alignment: Option<DateTimeAlignment>,
309        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
310            let prefs = (&locale.0).into();
311            let mut options = icu_datetime::fieldsets::MDET::with_length(map_or_default(length));
312            options.time_precision = time_precision.map(Into::into);
313            options.alignment = alignment.map(Into::into);
314            Ok(Box::new(Self(
315                icu_datetime
316                    ::DateTimeFormatter
317                    ::try_new(
318                        prefs,
319                        options
320                    )?
321                .cast_into_fset(),
322            )))
323        }
324        
325        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdet_with_provider")]
326        #[diplomat::rust_link(icu::datetime::fieldsets::MDET, Struct)]
327        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_time_precision, FnInStruct, compact)]
328        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_alignment, FnInStruct, compact)]
329        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_length, FnInStruct, compact)]
330        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::short, FnInStruct, hidden)]
331        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::medium, FnInStruct, hidden)]
332        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::long, FnInStruct, hidden)]
333        #[cfg(feature = "buffer_provider")]
334        pub fn create_mdet_with_provider(
335            provider: &DataProvider,
336            locale: &Locale,
337            length: Option<DateTimeLength>,
338            time_precision: Option<TimePrecision>,
339            alignment: Option<DateTimeAlignment>,
340        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
341            let prefs = (&locale.0).into();
342            let mut options = icu_datetime::fieldsets::MDET::with_length(map_or_default(length));
343            options.time_precision = time_precision.map(Into::into);
344            options.alignment = alignment.map(Into::into);
345            Ok(Box::new(Self(
346                icu_datetime
347                    ::DateTimeFormatter
348                    ::try_new_with_buffer_provider(
349                        provider.get()?,
350                        prefs,
351                        options
352                    )?
353                .cast_into_fset(),
354            )))
355        }
356        
357        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdet")]
358        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET, Struct)]
359        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_time_precision, FnInStruct, compact)]
360        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_alignment, FnInStruct, compact)]
361        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_year_style, FnInStruct, compact)]
362        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_length, FnInStruct, compact)]
363        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::short, FnInStruct, hidden)]
364        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::medium, FnInStruct, hidden)]
365        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::long, FnInStruct, hidden)]
366        #[cfg(feature = "compiled_data")]
367        pub fn create_ymdet(
368            locale: &Locale,
369            length: Option<DateTimeLength>,
370            time_precision: Option<TimePrecision>,
371            alignment: Option<DateTimeAlignment>,
372            year_style: Option<YearStyle>,
373        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
374            let prefs = (&locale.0).into();
375            let mut options = icu_datetime::fieldsets::YMDET::with_length(map_or_default(length));
376            options.time_precision = time_precision.map(Into::into);
377            options.alignment = alignment.map(Into::into);
378            options.year_style = year_style.map(Into::into);
379            Ok(Box::new(Self(
380                icu_datetime
381                    ::DateTimeFormatter
382                    ::try_new(
383                        prefs,
384                        options
385                    )?
386                .cast_into_fset(),
387            )))
388        }
389        
390        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdet_with_provider")]
391        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET, Struct)]
392        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_time_precision, FnInStruct, compact)]
393        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_alignment, FnInStruct, compact)]
394        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_year_style, FnInStruct, compact)]
395        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_length, FnInStruct, compact)]
396        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::short, FnInStruct, hidden)]
397        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::medium, FnInStruct, hidden)]
398        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::long, FnInStruct, hidden)]
399        #[cfg(feature = "buffer_provider")]
400        pub fn create_ymdet_with_provider(
401            provider: &DataProvider,
402            locale: &Locale,
403            length: Option<DateTimeLength>,
404            time_precision: Option<TimePrecision>,
405            alignment: Option<DateTimeAlignment>,
406            year_style: Option<YearStyle>,
407        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
408            let prefs = (&locale.0).into();
409            let mut options = icu_datetime::fieldsets::YMDET::with_length(map_or_default(length));
410            options.time_precision = time_precision.map(Into::into);
411            options.alignment = alignment.map(Into::into);
412            options.year_style = year_style.map(Into::into);
413            Ok(Box::new(Self(
414                icu_datetime
415                    ::DateTimeFormatter
416                    ::try_new_with_buffer_provider(
417                        provider.get()?,
418                        prefs,
419                        options
420                    )?
421                .cast_into_fset(),
422            )))
423        }
424        
425        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "et")]
426        #[diplomat::rust_link(icu::datetime::fieldsets::ET, Struct)]
427        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_time_precision, FnInStruct, compact)]
428        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_alignment, FnInStruct, compact)]
429        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_length, FnInStruct, compact)]
430        #[diplomat::rust_link(icu::datetime::fieldsets::ET::short, FnInStruct, hidden)]
431        #[diplomat::rust_link(icu::datetime::fieldsets::ET::medium, FnInStruct, hidden)]
432        #[diplomat::rust_link(icu::datetime::fieldsets::ET::long, FnInStruct, hidden)]
433        #[cfg(feature = "compiled_data")]
434        pub fn create_et(
435            locale: &Locale,
436            length: Option<DateTimeLength>,
437            time_precision: Option<TimePrecision>,
438            alignment: Option<DateTimeAlignment>,
439        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
440            let prefs = (&locale.0).into();
441            let mut options = icu_datetime::fieldsets::ET::with_length(map_or_default(length));
442            options.time_precision = time_precision.map(Into::into);
443            options.alignment = alignment.map(Into::into);
444            Ok(Box::new(Self(
445                icu_datetime
446                    ::DateTimeFormatter
447                    ::try_new(
448                        prefs,
449                        options
450                    )?
451                .cast_into_fset(),
452            )))
453        }
454        
455        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "et_with_provider")]
456        #[diplomat::rust_link(icu::datetime::fieldsets::ET, Struct)]
457        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_time_precision, FnInStruct, compact)]
458        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_alignment, FnInStruct, compact)]
459        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_length, FnInStruct, compact)]
460        #[diplomat::rust_link(icu::datetime::fieldsets::ET::short, FnInStruct, hidden)]
461        #[diplomat::rust_link(icu::datetime::fieldsets::ET::medium, FnInStruct, hidden)]
462        #[diplomat::rust_link(icu::datetime::fieldsets::ET::long, FnInStruct, hidden)]
463        #[cfg(feature = "buffer_provider")]
464        pub fn create_et_with_provider(
465            provider: &DataProvider,
466            locale: &Locale,
467            length: Option<DateTimeLength>,
468            time_precision: Option<TimePrecision>,
469            alignment: Option<DateTimeAlignment>,
470        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
471            let prefs = (&locale.0).into();
472            let mut options = icu_datetime::fieldsets::ET::with_length(map_or_default(length));
473            options.time_precision = time_precision.map(Into::into);
474            options.alignment = alignment.map(Into::into);
475            Ok(Box::new(Self(
476                icu_datetime
477                    ::DateTimeFormatter
478                    ::try_new_with_buffer_provider(
479                        provider.get()?,
480                        prefs,
481                        options
482                    )?
483                .cast_into_fset(),
484            )))
485        }
486        
487        #[diplomat::rust_link(icu::datetime::DateTimeFormatter::format, FnInStruct)]
488        #[diplomat::rust_link(icu::datetime::FormattedDateTime, Struct, hidden)]
489        #[diplomat::rust_link(icu::datetime::FormattedDateTime::to_string, FnInStruct, hidden)]
490        pub fn format_iso(
491            &self,
492            date: &IsoDate,
493            time: &Time,
494            write: &mut diplomat_runtime::DiplomatWrite,
495        ) {
496            let date = date.0;
497            let value = icu_time::DateTime {
498                date,
499                time: time.0,
500            };
501            let _infallible = self.0.format(&value).write_to(write);
502        }
503        
504        #[diplomat::rust_link(icu::datetime::DateTimeFormatter::format_same_calendar, FnInStruct)]
505        #[diplomat::rust_link(icu::datetime::FormattedDateTime, Struct, hidden)]
506        #[diplomat::rust_link(icu::datetime::FormattedDateTime::to_string, FnInStruct, hidden)]
507        pub fn format_same_calendar(
508            &self,
509            date: &Date,
510            time: &Time,
511            write: &mut diplomat_runtime::DiplomatWrite,
512        ) -> Result<(), DateTimeMismatchedCalendarError> {
513            let date = date.0.as_borrowed();
514            let value = icu_time::DateTime {
515                date,
516                time: time.0,
517            };
518            let _infallible = self.0.format_same_calendar(&value)?.write_to(write);
519            Ok(())
520        }
521    }
522    
523
524    #[diplomat::opaque]
525    #[diplomat::rust_link(icu::datetime::FixedCalendarDateTimeFormatter, Typedef)]
526    pub struct DateTimeFormatterGregorian(
527        pub  icu_datetime::FixedCalendarDateTimeFormatter<
528            Gregorian,
529            icu_datetime::fieldsets::enums::CompositeDateTimeFieldSet,
530        >,
531    );
532
533    impl DateTimeFormatterGregorian {
534        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "dt")]
535        #[diplomat::rust_link(icu::datetime::fieldsets::DT, Struct)]
536        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_time_precision, FnInStruct, compact)]
537        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_alignment, FnInStruct, compact)]
538        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_length, FnInStruct, compact)]
539        #[diplomat::rust_link(icu::datetime::fieldsets::DT::short, FnInStruct, hidden)]
540        #[diplomat::rust_link(icu::datetime::fieldsets::DT::medium, FnInStruct, hidden)]
541        #[diplomat::rust_link(icu::datetime::fieldsets::DT::long, FnInStruct, hidden)]
542        #[cfg(feature = "compiled_data")]
543        pub fn create_dt(
544            locale: &Locale,
545            length: Option<DateTimeLength>,
546            time_precision: Option<TimePrecision>,
547            alignment: Option<DateTimeAlignment>,
548        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
549            let prefs = (&locale.0).into();
550            let mut options = icu_datetime::fieldsets::DT::with_length(map_or_default(length));
551            options.time_precision = time_precision.map(Into::into);
552            options.alignment = alignment.map(Into::into);
553            Ok(Box::new(Self(
554                icu_datetime
555                    ::FixedCalendarDateTimeFormatter
556                    ::try_new(
557                        prefs,
558                        options
559                    )?
560                .cast_into_fset(),
561            )))
562        }
563        
564        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "dt_with_provider")]
565        #[diplomat::rust_link(icu::datetime::fieldsets::DT, Struct)]
566        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_time_precision, FnInStruct, compact)]
567        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_alignment, FnInStruct, compact)]
568        #[diplomat::rust_link(icu::datetime::fieldsets::DT::with_length, FnInStruct, compact)]
569        #[diplomat::rust_link(icu::datetime::fieldsets::DT::short, FnInStruct, hidden)]
570        #[diplomat::rust_link(icu::datetime::fieldsets::DT::medium, FnInStruct, hidden)]
571        #[diplomat::rust_link(icu::datetime::fieldsets::DT::long, FnInStruct, hidden)]
572        #[cfg(feature = "buffer_provider")]
573        pub fn create_dt_with_provider(
574            provider: &DataProvider,
575            locale: &Locale,
576            length: Option<DateTimeLength>,
577            time_precision: Option<TimePrecision>,
578            alignment: Option<DateTimeAlignment>,
579        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
580            let prefs = (&locale.0).into();
581            let mut options = icu_datetime::fieldsets::DT::with_length(map_or_default(length));
582            options.time_precision = time_precision.map(Into::into);
583            options.alignment = alignment.map(Into::into);
584            Ok(Box::new(Self(
585                icu_datetime
586                    ::FixedCalendarDateTimeFormatter
587                    ::try_new_with_buffer_provider(
588                        provider.get()?,
589                        prefs,
590                        options
591                    )?
592                .cast_into_fset(),
593            )))
594        }
595        
596        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdt")]
597        #[diplomat::rust_link(icu::datetime::fieldsets::MDT, Struct)]
598        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_time_precision, FnInStruct, compact)]
599        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_alignment, FnInStruct, compact)]
600        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_length, FnInStruct, compact)]
601        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::short, FnInStruct, hidden)]
602        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::medium, FnInStruct, hidden)]
603        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::long, FnInStruct, hidden)]
604        #[cfg(feature = "compiled_data")]
605        pub fn create_mdt(
606            locale: &Locale,
607            length: Option<DateTimeLength>,
608            time_precision: Option<TimePrecision>,
609            alignment: Option<DateTimeAlignment>,
610        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
611            let prefs = (&locale.0).into();
612            let mut options = icu_datetime::fieldsets::MDT::with_length(map_or_default(length));
613            options.time_precision = time_precision.map(Into::into);
614            options.alignment = alignment.map(Into::into);
615            Ok(Box::new(Self(
616                icu_datetime
617                    ::FixedCalendarDateTimeFormatter
618                    ::try_new(
619                        prefs,
620                        options
621                    )?
622                .cast_into_fset(),
623            )))
624        }
625        
626        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdt_with_provider")]
627        #[diplomat::rust_link(icu::datetime::fieldsets::MDT, Struct)]
628        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_time_precision, FnInStruct, compact)]
629        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_alignment, FnInStruct, compact)]
630        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::with_length, FnInStruct, compact)]
631        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::short, FnInStruct, hidden)]
632        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::medium, FnInStruct, hidden)]
633        #[diplomat::rust_link(icu::datetime::fieldsets::MDT::long, FnInStruct, hidden)]
634        #[cfg(feature = "buffer_provider")]
635        pub fn create_mdt_with_provider(
636            provider: &DataProvider,
637            locale: &Locale,
638            length: Option<DateTimeLength>,
639            time_precision: Option<TimePrecision>,
640            alignment: Option<DateTimeAlignment>,
641        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
642            let prefs = (&locale.0).into();
643            let mut options = icu_datetime::fieldsets::MDT::with_length(map_or_default(length));
644            options.time_precision = time_precision.map(Into::into);
645            options.alignment = alignment.map(Into::into);
646            Ok(Box::new(Self(
647                icu_datetime
648                    ::FixedCalendarDateTimeFormatter
649                    ::try_new_with_buffer_provider(
650                        provider.get()?,
651                        prefs,
652                        options
653                    )?
654                .cast_into_fset(),
655            )))
656        }
657        
658        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdt")]
659        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT, Struct)]
660        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_time_precision, FnInStruct, compact)]
661        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_alignment, FnInStruct, compact)]
662        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_year_style, FnInStruct, compact)]
663        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_length, FnInStruct, compact)]
664        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::short, FnInStruct, hidden)]
665        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::medium, FnInStruct, hidden)]
666        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::long, FnInStruct, hidden)]
667        #[diplomat::demo(default_constructor)]
668        #[cfg(feature = "compiled_data")]
669        pub fn create_ymdt(
670            locale: &Locale,
671            length: Option<DateTimeLength>,
672            time_precision: Option<TimePrecision>,
673            alignment: Option<DateTimeAlignment>,
674            year_style: Option<YearStyle>,
675        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
676            let prefs = (&locale.0).into();
677            let mut options = icu_datetime::fieldsets::YMDT::with_length(map_or_default(length));
678            options.time_precision = time_precision.map(Into::into);
679            options.alignment = alignment.map(Into::into);
680            options.year_style = year_style.map(Into::into);
681            Ok(Box::new(Self(
682                icu_datetime
683                    ::FixedCalendarDateTimeFormatter
684                    ::try_new(
685                        prefs,
686                        options
687                    )?
688                .cast_into_fset(),
689            )))
690        }
691        
692        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdt_with_provider")]
693        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT, Struct)]
694        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_time_precision, FnInStruct, compact)]
695        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_alignment, FnInStruct, compact)]
696        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_year_style, FnInStruct, compact)]
697        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::with_length, FnInStruct, compact)]
698        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::short, FnInStruct, hidden)]
699        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::medium, FnInStruct, hidden)]
700        #[diplomat::rust_link(icu::datetime::fieldsets::YMDT::long, FnInStruct, hidden)]
701        #[cfg(feature = "buffer_provider")]
702        pub fn create_ymdt_with_provider(
703            provider: &DataProvider,
704            locale: &Locale,
705            length: Option<DateTimeLength>,
706            time_precision: Option<TimePrecision>,
707            alignment: Option<DateTimeAlignment>,
708            year_style: Option<YearStyle>,
709        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
710            let prefs = (&locale.0).into();
711            let mut options = icu_datetime::fieldsets::YMDT::with_length(map_or_default(length));
712            options.time_precision = time_precision.map(Into::into);
713            options.alignment = alignment.map(Into::into);
714            options.year_style = year_style.map(Into::into);
715            Ok(Box::new(Self(
716                icu_datetime
717                    ::FixedCalendarDateTimeFormatter
718                    ::try_new_with_buffer_provider(
719                        provider.get()?,
720                        prefs,
721                        options
722                    )?
723                .cast_into_fset(),
724            )))
725        }
726        
727        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "det")]
728        #[diplomat::rust_link(icu::datetime::fieldsets::DET, Struct)]
729        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_time_precision, FnInStruct, compact)]
730        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_alignment, FnInStruct, compact)]
731        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_length, FnInStruct, compact)]
732        #[diplomat::rust_link(icu::datetime::fieldsets::DET::short, FnInStruct, hidden)]
733        #[diplomat::rust_link(icu::datetime::fieldsets::DET::medium, FnInStruct, hidden)]
734        #[diplomat::rust_link(icu::datetime::fieldsets::DET::long, FnInStruct, hidden)]
735        #[cfg(feature = "compiled_data")]
736        pub fn create_det(
737            locale: &Locale,
738            length: Option<DateTimeLength>,
739            time_precision: Option<TimePrecision>,
740            alignment: Option<DateTimeAlignment>,
741        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
742            let prefs = (&locale.0).into();
743            let mut options = icu_datetime::fieldsets::DET::with_length(map_or_default(length));
744            options.time_precision = time_precision.map(Into::into);
745            options.alignment = alignment.map(Into::into);
746            Ok(Box::new(Self(
747                icu_datetime
748                    ::FixedCalendarDateTimeFormatter
749                    ::try_new(
750                        prefs,
751                        options
752                    )?
753                .cast_into_fset(),
754            )))
755        }
756        
757        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "det_with_provider")]
758        #[diplomat::rust_link(icu::datetime::fieldsets::DET, Struct)]
759        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_time_precision, FnInStruct, compact)]
760        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_alignment, FnInStruct, compact)]
761        #[diplomat::rust_link(icu::datetime::fieldsets::DET::with_length, FnInStruct, compact)]
762        #[diplomat::rust_link(icu::datetime::fieldsets::DET::short, FnInStruct, hidden)]
763        #[diplomat::rust_link(icu::datetime::fieldsets::DET::medium, FnInStruct, hidden)]
764        #[diplomat::rust_link(icu::datetime::fieldsets::DET::long, FnInStruct, hidden)]
765        #[cfg(feature = "buffer_provider")]
766        pub fn create_det_with_provider(
767            provider: &DataProvider,
768            locale: &Locale,
769            length: Option<DateTimeLength>,
770            time_precision: Option<TimePrecision>,
771            alignment: Option<DateTimeAlignment>,
772        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
773            let prefs = (&locale.0).into();
774            let mut options = icu_datetime::fieldsets::DET::with_length(map_or_default(length));
775            options.time_precision = time_precision.map(Into::into);
776            options.alignment = alignment.map(Into::into);
777            Ok(Box::new(Self(
778                icu_datetime
779                    ::FixedCalendarDateTimeFormatter
780                    ::try_new_with_buffer_provider(
781                        provider.get()?,
782                        prefs,
783                        options
784                    )?
785                .cast_into_fset(),
786            )))
787        }
788        
789        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdet")]
790        #[diplomat::rust_link(icu::datetime::fieldsets::MDET, Struct)]
791        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_time_precision, FnInStruct, compact)]
792        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_alignment, FnInStruct, compact)]
793        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_length, FnInStruct, compact)]
794        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::short, FnInStruct, hidden)]
795        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::medium, FnInStruct, hidden)]
796        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::long, FnInStruct, hidden)]
797        #[cfg(feature = "compiled_data")]
798        pub fn create_mdet(
799            locale: &Locale,
800            length: Option<DateTimeLength>,
801            time_precision: Option<TimePrecision>,
802            alignment: Option<DateTimeAlignment>,
803        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
804            let prefs = (&locale.0).into();
805            let mut options = icu_datetime::fieldsets::MDET::with_length(map_or_default(length));
806            options.time_precision = time_precision.map(Into::into);
807            options.alignment = alignment.map(Into::into);
808            Ok(Box::new(Self(
809                icu_datetime
810                    ::FixedCalendarDateTimeFormatter
811                    ::try_new(
812                        prefs,
813                        options
814                    )?
815                .cast_into_fset(),
816            )))
817        }
818        
819        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "mdet_with_provider")]
820        #[diplomat::rust_link(icu::datetime::fieldsets::MDET, Struct)]
821        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_time_precision, FnInStruct, compact)]
822        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_alignment, FnInStruct, compact)]
823        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::with_length, FnInStruct, compact)]
824        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::short, FnInStruct, hidden)]
825        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::medium, FnInStruct, hidden)]
826        #[diplomat::rust_link(icu::datetime::fieldsets::MDET::long, FnInStruct, hidden)]
827        #[cfg(feature = "buffer_provider")]
828        pub fn create_mdet_with_provider(
829            provider: &DataProvider,
830            locale: &Locale,
831            length: Option<DateTimeLength>,
832            time_precision: Option<TimePrecision>,
833            alignment: Option<DateTimeAlignment>,
834        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
835            let prefs = (&locale.0).into();
836            let mut options = icu_datetime::fieldsets::MDET::with_length(map_or_default(length));
837            options.time_precision = time_precision.map(Into::into);
838            options.alignment = alignment.map(Into::into);
839            Ok(Box::new(Self(
840                icu_datetime
841                    ::FixedCalendarDateTimeFormatter
842                    ::try_new_with_buffer_provider(
843                        provider.get()?,
844                        prefs,
845                        options
846                    )?
847                .cast_into_fset(),
848            )))
849        }
850        
851        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdet")]
852        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET, Struct)]
853        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_time_precision, FnInStruct, compact)]
854        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_alignment, FnInStruct, compact)]
855        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_year_style, FnInStruct, compact)]
856        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_length, FnInStruct, compact)]
857        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::short, FnInStruct, hidden)]
858        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::medium, FnInStruct, hidden)]
859        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::long, FnInStruct, hidden)]
860        #[cfg(feature = "compiled_data")]
861        pub fn create_ymdet(
862            locale: &Locale,
863            length: Option<DateTimeLength>,
864            time_precision: Option<TimePrecision>,
865            alignment: Option<DateTimeAlignment>,
866            year_style: Option<YearStyle>,
867        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
868            let prefs = (&locale.0).into();
869            let mut options = icu_datetime::fieldsets::YMDET::with_length(map_or_default(length));
870            options.time_precision = time_precision.map(Into::into);
871            options.alignment = alignment.map(Into::into);
872            options.year_style = year_style.map(Into::into);
873            Ok(Box::new(Self(
874                icu_datetime
875                    ::FixedCalendarDateTimeFormatter
876                    ::try_new(
877                        prefs,
878                        options
879                    )?
880                .cast_into_fset(),
881            )))
882        }
883        
884        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "ymdet_with_provider")]
885        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET, Struct)]
886        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_time_precision, FnInStruct, compact)]
887        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_alignment, FnInStruct, compact)]
888        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_year_style, FnInStruct, compact)]
889        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::with_length, FnInStruct, compact)]
890        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::short, FnInStruct, hidden)]
891        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::medium, FnInStruct, hidden)]
892        #[diplomat::rust_link(icu::datetime::fieldsets::YMDET::long, FnInStruct, hidden)]
893        #[cfg(feature = "buffer_provider")]
894        pub fn create_ymdet_with_provider(
895            provider: &DataProvider,
896            locale: &Locale,
897            length: Option<DateTimeLength>,
898            time_precision: Option<TimePrecision>,
899            alignment: Option<DateTimeAlignment>,
900            year_style: Option<YearStyle>,
901        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
902            let prefs = (&locale.0).into();
903            let mut options = icu_datetime::fieldsets::YMDET::with_length(map_or_default(length));
904            options.time_precision = time_precision.map(Into::into);
905            options.alignment = alignment.map(Into::into);
906            options.year_style = year_style.map(Into::into);
907            Ok(Box::new(Self(
908                icu_datetime
909                    ::FixedCalendarDateTimeFormatter
910                    ::try_new_with_buffer_provider(
911                        provider.get()?,
912                        prefs,
913                        options
914                    )?
915                .cast_into_fset(),
916            )))
917        }
918        
919        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "et")]
920        #[diplomat::rust_link(icu::datetime::fieldsets::ET, Struct)]
921        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_time_precision, FnInStruct, compact)]
922        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_alignment, FnInStruct, compact)]
923        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_length, FnInStruct, compact)]
924        #[diplomat::rust_link(icu::datetime::fieldsets::ET::short, FnInStruct, hidden)]
925        #[diplomat::rust_link(icu::datetime::fieldsets::ET::medium, FnInStruct, hidden)]
926        #[diplomat::rust_link(icu::datetime::fieldsets::ET::long, FnInStruct, hidden)]
927        #[cfg(feature = "compiled_data")]
928        pub fn create_et(
929            locale: &Locale,
930            length: Option<DateTimeLength>,
931            time_precision: Option<TimePrecision>,
932            alignment: Option<DateTimeAlignment>,
933        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
934            let prefs = (&locale.0).into();
935            let mut options = icu_datetime::fieldsets::ET::with_length(map_or_default(length));
936            options.time_precision = time_precision.map(Into::into);
937            options.alignment = alignment.map(Into::into);
938            Ok(Box::new(Self(
939                icu_datetime
940                    ::FixedCalendarDateTimeFormatter
941                    ::try_new(
942                        prefs,
943                        options
944                    )?
945                .cast_into_fset(),
946            )))
947        }
948        
949        #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "et_with_provider")]
950        #[diplomat::rust_link(icu::datetime::fieldsets::ET, Struct)]
951        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_time_precision, FnInStruct, compact)]
952        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_alignment, FnInStruct, compact)]
953        #[diplomat::rust_link(icu::datetime::fieldsets::ET::with_length, FnInStruct, compact)]
954        #[diplomat::rust_link(icu::datetime::fieldsets::ET::short, FnInStruct, hidden)]
955        #[diplomat::rust_link(icu::datetime::fieldsets::ET::medium, FnInStruct, hidden)]
956        #[diplomat::rust_link(icu::datetime::fieldsets::ET::long, FnInStruct, hidden)]
957        #[cfg(feature = "buffer_provider")]
958        pub fn create_et_with_provider(
959            provider: &DataProvider,
960            locale: &Locale,
961            length: Option<DateTimeLength>,
962            time_precision: Option<TimePrecision>,
963            alignment: Option<DateTimeAlignment>,
964        ) -> Result<Box<Self>, DateTimeFormatterLoadError> {
965            let prefs = (&locale.0).into();
966            let mut options = icu_datetime::fieldsets::ET::with_length(map_or_default(length));
967            options.time_precision = time_precision.map(Into::into);
968            options.alignment = alignment.map(Into::into);
969            Ok(Box::new(Self(
970                icu_datetime
971                    ::FixedCalendarDateTimeFormatter
972                    ::try_new_with_buffer_provider(
973                        provider.get()?,
974                        prefs,
975                        options
976                    )?
977                .cast_into_fset(),
978            )))
979        }
980        
981        #[diplomat::rust_link(icu::datetime::FixedCalendarDateTimeFormatter::format, FnInStruct)]
982        #[diplomat::rust_link(icu::datetime::FormattedDateTime, Struct, hidden)]
983        #[diplomat::rust_link(icu::datetime::FormattedDateTime::to_string, FnInStruct, hidden)]
984        pub fn format_iso(
985            &self,
986            date: &IsoDate,
987            time: &Time,
988            write: &mut diplomat_runtime::DiplomatWrite,
989        ) {
990            let date = date.0.to_calendar(Gregorian);
991            let value = icu_time::DateTime {
992                date,
993                time: time.0,
994            };
995            let _infallible = self.0.format(&value).write_to(write);
996        }
997        
998    }
999    
1000}