| // generated by diplomat-tool |
| |
| part of 'lib.g.dart'; |
| |
| /// A locale expander. |
| /// |
| /// See the [Rust documentation for `LocaleExpander`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html) for more information. |
| final class LocaleExpander implements ffi.Finalizable { |
| final ffi.Pointer<ffi.Opaque> _ffi; |
| |
| // These are "used" in the sense that they keep dependencies alive |
| // ignore: unused_field |
| final core.List<Object> _selfEdge; |
| |
| // This takes in a list of lifetime edges (including for &self borrows) |
| // corresponding to data this may borrow from. These should be flat arrays containing |
| // references to objects, and this object will hold on to them to keep them alive and |
| // maintain borrow validity. |
| LocaleExpander._fromFfi(this._ffi, this._selfEdge) { |
| if (_selfEdge.isEmpty) { |
| _finalizer.attach(this, _ffi.cast()); |
| } |
| } |
| |
| static final _finalizer = |
| ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XLocaleExpander_destroy)); |
| |
| /// Create a new [`LocaleExpander`]. |
| /// |
| /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.new) for more information. |
| /// |
| /// Throws [Error] on failure. |
| factory LocaleExpander(DataProvider provider) { |
| final result = _ICU4XLocaleExpander_create(provider._ffi); |
| if (!result.isOk) { |
| throw Error.values.firstWhere((v) => v._ffi == result.union.err); |
| } |
| return LocaleExpander._fromFfi(result.union.ok, []); |
| } |
| |
| /// Create a new [`LocaleExpander`] with extended data. |
| /// |
| /// See the [Rust documentation for `new_extended`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.new_extended) for more information. |
| /// |
| /// Throws [Error] on failure. |
| factory LocaleExpander.extended(DataProvider provider) { |
| final result = _ICU4XLocaleExpander_create_extended(provider._ffi); |
| if (!result.isOk) { |
| throw Error.values.firstWhere((v) => v._ffi == result.union.err); |
| } |
| return LocaleExpander._fromFfi(result.union.ok, []); |
| } |
| |
| /// See the [Rust documentation for `maximize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.maximize) for more information. |
| TransformResult maximize(Locale locale) { |
| final result = _ICU4XLocaleExpander_maximize(_ffi, locale._ffi); |
| return TransformResult.values[result]; |
| } |
| |
| /// See the [Rust documentation for `minimize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.minimize) for more information. |
| TransformResult minimize(Locale locale) { |
| final result = _ICU4XLocaleExpander_minimize(_ffi, locale._ffi); |
| return TransformResult.values[result]; |
| } |
| |
| /// See the [Rust documentation for `minimize_favor_script`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.minimize_favor_script) for more information. |
| TransformResult minimizeFavorScript(Locale locale) { |
| final result = |
| _ICU4XLocaleExpander_minimize_favor_script(_ffi, locale._ffi); |
| return TransformResult.values[result]; |
| } |
| } |
| |
| @meta.ResourceIdentifier('ICU4XLocaleExpander_destroy') |
| @ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>( |
| isLeaf: true, symbol: 'ICU4XLocaleExpander_destroy') |
| // ignore: non_constant_identifier_names |
| external void _ICU4XLocaleExpander_destroy(ffi.Pointer<ffi.Void> self); |
| |
| @meta.ResourceIdentifier('ICU4XLocaleExpander_create') |
| @ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer<ffi.Opaque>)>( |
| isLeaf: true, symbol: 'ICU4XLocaleExpander_create') |
| // ignore: non_constant_identifier_names |
| external _ResultOpaqueInt32 _ICU4XLocaleExpander_create( |
| ffi.Pointer<ffi.Opaque> provider); |
| |
| @meta.ResourceIdentifier('ICU4XLocaleExpander_create_extended') |
| @ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer<ffi.Opaque>)>( |
| isLeaf: true, symbol: 'ICU4XLocaleExpander_create_extended') |
| // ignore: non_constant_identifier_names |
| external _ResultOpaqueInt32 _ICU4XLocaleExpander_create_extended( |
| ffi.Pointer<ffi.Opaque> provider); |
| |
| @meta.ResourceIdentifier('ICU4XLocaleExpander_maximize') |
| @ffi.Native< |
| ffi.Int32 Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>( |
| isLeaf: true, symbol: 'ICU4XLocaleExpander_maximize') |
| // ignore: non_constant_identifier_names |
| external int _ICU4XLocaleExpander_maximize( |
| ffi.Pointer<ffi.Opaque> self, ffi.Pointer<ffi.Opaque> locale); |
| |
| @meta.ResourceIdentifier('ICU4XLocaleExpander_minimize') |
| @ffi.Native< |
| ffi.Int32 Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>( |
| isLeaf: true, symbol: 'ICU4XLocaleExpander_minimize') |
| // ignore: non_constant_identifier_names |
| external int _ICU4XLocaleExpander_minimize( |
| ffi.Pointer<ffi.Opaque> self, ffi.Pointer<ffi.Opaque> locale); |
| |
| @meta.ResourceIdentifier('ICU4XLocaleExpander_minimize_favor_script') |
| @ffi.Native< |
| ffi.Int32 Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>( |
| isLeaf: true, symbol: 'ICU4XLocaleExpander_minimize_favor_script') |
| // ignore: non_constant_identifier_names |
| external int _ICU4XLocaleExpander_minimize_favor_script( |
| ffi.Pointer<ffi.Opaque> self, ffi.Pointer<ffi.Opaque> locale); |