// generated by diplomat-tool
// dart format off

part of 'lib.g.dart';

/// See the [Rust documentation for `CaseMapper`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapper.html) for more information.
final class CaseMapper 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.
  CaseMapper._fromFfi(this._ffi, this._selfEdge) {
    if (_selfEdge.isEmpty) {
      _icu4x_CaseMapper_destroy_mv1(this, _ffi.cast());
    }
  }

  // ignore: experimental_member_use
  @meta.RecordUse()
  // ignore: non_constant_identifier_names
  static void _icu4x_CaseMapper_destroy_mv1(CaseMapper cl, ffi.Pointer<ffi.Void> pointer) => _finalizer.attach(cl, pointer);

  static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_internal_icu4x_CaseMapper_destroy_mv1));

  /// Construct a new `CaseMapper` instance using compiled data.
  ///
  /// See the [Rust documentation for `new`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapper.html#method.new) for more information.
  factory CaseMapper() {
    final result = _icu4x_CaseMapper_create_mv1();
    return CaseMapper._fromFfi(result, []);
  }

  /// Construct a new `CaseMapper` instance using a particular data source.
  ///
  /// See the [Rust documentation for `new`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapper.html#method.new) for more information.
  ///
  /// Throws [DataError] on failure.
  factory CaseMapper.withProvider(DataProvider provider) {
    final result = _icu4x_CaseMapper_create_with_provider_mv1(provider._ffi);
    if (!result.isOk) {
      throw DataError.values[result.union.err];
    }
    return CaseMapper._fromFfi(result.union.ok, []);
  }

  /// Returns the full lowercase mapping of the given string
  ///
  /// See the [Rust documentation for `lowercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.lowercase) for more information.
  String lowercase(String s, Locale locale) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_lowercase_mv1(_ffi, s._utf8AllocIn(temp.arena), locale._ffi, write._ffi);
    return write.finalize();
  }

  /// Returns the full uppercase mapping of the given string
  ///
  /// See the [Rust documentation for `uppercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.uppercase) for more information.
  String uppercase(String s, Locale locale) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_uppercase_mv1(_ffi, s._utf8AllocIn(temp.arena), locale._ffi, write._ffi);
    return write.finalize();
  }

  /// Returns the full lowercase mapping of the given string, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `lowercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.lowercase) for more information.
  static String lowercaseWithCompiledData(String s, Locale locale) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_lowercase_with_compiled_data_mv1(s._utf8AllocIn(temp.arena), locale._ffi, write._ffi);
    return write.finalize();
  }

  /// Returns the full uppercase mapping of the given string, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `uppercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.uppercase) for more information.
  static String uppercaseWithCompiledData(String s, Locale locale) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_uppercase_with_compiled_data_mv1(s._utf8AllocIn(temp.arena), locale._ffi, write._ffi);
    return write.finalize();
  }

  /// Returns the full titlecase mapping of the given string, performing head adjustment without
  /// loading additional data.
  /// (if head adjustment is enabled in the options)
  ///
  /// The `v1` refers to the version of the options struct, which may change as we add more options
  ///
  /// See the [Rust documentation for `titlecase_segment_with_only_case_data`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.titlecase_segment_with_only_case_data) for more information.
  String titlecaseSegmentWithOnlyCaseData(String s, Locale locale, TitlecaseOptions options) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_titlecase_segment_with_only_case_data_v1_mv1(_ffi, s._utf8AllocIn(temp.arena), locale._ffi, options._toFfi(temp.arena), write._ffi);
    return write.finalize();
  }

  /// Returns the full titlecase mapping of the given string, performing head adjustment without
  /// loading additional data, using compiled data (avoids having to allocate a `CaseMapper` object).
  ///
  /// (if head adjustment is enabled in the options)
  ///
  /// The `v1` refers to the version of the options struct, which may change as we add more options
  ///
  /// See the [Rust documentation for `titlecase_segment_with_only_case_data_to_string`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.titlecase_segment_with_only_case_data_to_string) for more information.
  static String titlecaseSegmentWithOnlyCaseCompiledData(String s, Locale locale, TitlecaseOptions options) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_titlecase_segment_with_only_case_compiled_data_v1_mv1(s._utf8AllocIn(temp.arena), locale._ffi, options._toFfi(temp.arena), write._ffi);
    return write.finalize();
  }

  /// Case-folds the characters in the given string
  ///
  /// See the [Rust documentation for `fold`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.fold) for more information.
  String fold(String s) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_fold_mv1(_ffi, s._utf8AllocIn(temp.arena), write._ffi);
    return write.finalize();
  }

  /// Case-folds the characters in the given string
  /// using Turkic (T) mappings for dotted/dotless I.
  ///
  /// See the [Rust documentation for `fold_turkic`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.fold_turkic) for more information.
  String foldTurkic(String s) {
    final temp = _FinalizedArena();
    final write = _Write();
    _icu4x_CaseMapper_fold_turkic_mv1(_ffi, s._utf8AllocIn(temp.arena), write._ffi);
    return write.finalize();
  }

  /// Adds all simple case mappings and the full case folding for `c` to `builder`.
  /// Also adds special case closure mappings.
  ///
  /// In other words, this adds all characters that this casemaps to, as
  /// well as all characters that may casemap to this one.
  ///
  /// Note that since `CodePointSetBuilder` does not contain strings, this will
  /// ignore string mappings.
  ///
  /// Identical to the similarly named method on `CaseMapCloser`, use that if you
  /// plan on using string case closure mappings too.
  ///
  /// See the [Rust documentation for `add_case_closure_to`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.add_case_closure_to) for more information.
  void addCaseClosureTo(Rune c, CodePointSetBuilder builder) {
    _icu4x_CaseMapper_add_case_closure_to_mv1(_ffi, c, builder._ffi);
  }

  /// Returns the simple lowercase mapping of the given character.
  ///
  /// This function only implements simple and common mappings.
  /// Full mappings, which can map one char to a string, are not included.
  /// For full mappings, use `CaseMapperBorrowed::lowercase`.
  ///
  /// See the [Rust documentation for `simple_lowercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_lowercase) for more information.
  Rune simpleLowercase(Rune ch) {
    final result = _icu4x_CaseMapper_simple_lowercase_mv1(_ffi, ch);
    return result;
  }

  /// Returns the simple lowercase mapping of the given character, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `simple_lowercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_lowercase) for more information.
  static Rune simpleLowercaseWithCompiledData(Rune ch) {
    final result = _icu4x_CaseMapper_simple_lowercase_with_compiled_data_mv1(ch);
    return result;
  }

  /// Returns the simple uppercase mapping of the given character.
  ///
  /// This function only implements simple and common mappings.
  /// Full mappings, which can map one char to a string, are not included.
  /// For full mappings, use `CaseMapperBorrowed::uppercase`.
  ///
  /// See the [Rust documentation for `simple_uppercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_uppercase) for more information.
  Rune simpleUppercase(Rune ch) {
    final result = _icu4x_CaseMapper_simple_uppercase_mv1(_ffi, ch);
    return result;
  }

  /// Returns the simple uppercase mapping of the given character, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `simple_uppercase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_uppercase) for more information.
  static Rune simpleUppercaseWithCompiledData(Rune ch) {
    final result = _icu4x_CaseMapper_simple_uppercase_with_compiled_data_mv1(ch);
    return result;
  }

  /// Returns the simple titlecase mapping of the given character.
  ///
  /// This function only implements simple and common mappings.
  /// Full mappings, which can map one char to a string, are not included.
  /// For full mappings, use `CaseMapperBorrowed::titlecase_segment`.
  ///
  /// See the [Rust documentation for `simple_titlecase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_titlecase) for more information.
  Rune simpleTitlecase(Rune ch) {
    final result = _icu4x_CaseMapper_simple_titlecase_mv1(_ffi, ch);
    return result;
  }

  /// Returns the simple titlecase mapping of the given character, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `simple_titlecase`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_titlecase) for more information.
  static Rune simpleTitlecaseWithCompiledData(Rune ch) {
    final result = _icu4x_CaseMapper_simple_titlecase_with_compiled_data_mv1(ch);
    return result;
  }

  /// Returns the simple casefolding of the given character.
  ///
  /// This function only implements simple folding.
  /// For full folding, use `CaseMapperBorrowed::fold`.
  ///
  /// See the [Rust documentation for `simple_fold`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_fold) for more information.
  Rune simpleFold(Rune ch) {
    final result = _icu4x_CaseMapper_simple_fold_mv1(_ffi, ch);
    return result;
  }

  /// Returns the simple casefolding of the given character, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `simple_fold`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_fold) for more information.
  static Rune simpleFoldWithCompiledData(Rune ch) {
    final result = _icu4x_CaseMapper_simple_fold_with_compiled_data_mv1(ch);
    return result;
  }

  /// Returns the simple casefolding of the given character in the Turkic locale.
  ///
  /// This function only implements simple folding.
  /// For full folding, use `CaseMapperBorrowed::fold_turkic`.
  ///
  /// See the [Rust documentation for `simple_fold_turkic`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_fold_turkic) for more information.
  Rune simpleFoldTurkic(Rune ch) {
    final result = _icu4x_CaseMapper_simple_fold_turkic_mv1(_ffi, ch);
    return result;
  }

  /// Returns the simple Turkic casefolding of the given character, using compiled data (avoids having to allocate a `CaseMapper` object)
  ///
  /// See the [Rust documentation for `simple_fold_turkic`](https://docs.rs/icu/2.2.0/icu/casemap/struct.CaseMapperBorrowed.html#method.simple_fold_turkic) for more information.
  static Rune simpleFoldTurkicWithCompiledData(Rune ch) {
    final result = _icu4x_CaseMapper_simple_fold_turkic_with_compiled_data_mv1(ch);
    return result;
  }

}

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_destroy_mv1')
// ignore: non_constant_identifier_names
external void _internal_icu4x_CaseMapper_destroy_mv1(ffi.Pointer<ffi.Void> self);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function()>(isLeaf: true, symbol: 'icu4x_CaseMapper_create_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_CaseMapper_create_mv1();

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_create_with_provider_mv1')
// ignore: non_constant_identifier_names
external _ResultOpaqueInt32 _icu4x_CaseMapper_create_with_provider_mv1(ffi.Pointer<ffi.Opaque> provider);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Opaque>, _SliceUtf8, ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_lowercase_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_lowercase_mv1(ffi.Pointer<ffi.Opaque> self, _SliceUtf8 s, ffi.Pointer<ffi.Opaque> locale, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Opaque>, _SliceUtf8, ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_uppercase_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_uppercase_mv1(ffi.Pointer<ffi.Opaque> self, _SliceUtf8 s, ffi.Pointer<ffi.Opaque> locale, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(_SliceUtf8, ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_lowercase_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_lowercase_with_compiled_data_mv1(_SliceUtf8 s, ffi.Pointer<ffi.Opaque> locale, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(_SliceUtf8, ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_uppercase_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_uppercase_with_compiled_data_mv1(_SliceUtf8 s, ffi.Pointer<ffi.Opaque> locale, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Opaque>, _SliceUtf8, ffi.Pointer<ffi.Opaque>, _TitlecaseOptionsFfi, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_titlecase_segment_with_only_case_data_v1_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_titlecase_segment_with_only_case_data_v1_mv1(ffi.Pointer<ffi.Opaque> self, _SliceUtf8 s, ffi.Pointer<ffi.Opaque> locale, _TitlecaseOptionsFfi options, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(_SliceUtf8, ffi.Pointer<ffi.Opaque>, _TitlecaseOptionsFfi, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_titlecase_segment_with_only_case_compiled_data_v1_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_titlecase_segment_with_only_case_compiled_data_v1_mv1(_SliceUtf8 s, ffi.Pointer<ffi.Opaque> locale, _TitlecaseOptionsFfi options, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Opaque>, _SliceUtf8, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_fold_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_fold_mv1(ffi.Pointer<ffi.Opaque> self, _SliceUtf8 s, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Opaque>, _SliceUtf8, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_fold_turkic_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_fold_turkic_mv1(ffi.Pointer<ffi.Opaque> self, _SliceUtf8 s, ffi.Pointer<ffi.Opaque> write);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Opaque>, ffi.Uint32, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_CaseMapper_add_case_closure_to_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_CaseMapper_add_case_closure_to_mv1(ffi.Pointer<ffi.Opaque> self, Rune c, ffi.Pointer<ffi.Opaque> builder);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_lowercase_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_lowercase_mv1(ffi.Pointer<ffi.Opaque> self, Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_lowercase_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_lowercase_with_compiled_data_mv1(Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_uppercase_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_uppercase_mv1(ffi.Pointer<ffi.Opaque> self, Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_uppercase_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_uppercase_with_compiled_data_mv1(Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_titlecase_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_titlecase_mv1(ffi.Pointer<ffi.Opaque> self, Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_titlecase_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_titlecase_with_compiled_data_mv1(Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_fold_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_fold_mv1(ffi.Pointer<ffi.Opaque> self, Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_fold_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_fold_with_compiled_data_mv1(Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>, ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_fold_turkic_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_fold_turkic_mv1(ffi.Pointer<ffi.Opaque> self, Rune ch);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Uint32 Function(ffi.Uint32)>(isLeaf: true, symbol: 'icu4x_CaseMapper_simple_fold_turkic_with_compiled_data_mv1')
// ignore: non_constant_identifier_names
external Rune _icu4x_CaseMapper_simple_fold_turkic_with_compiled_data_mv1(Rune ch);

// dart format on
