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

part of 'lib.g.dart';

final class _TitlecaseOptionsFfi extends ffi.Struct {
  external _ResultInt32Void leadingAdjustment;
  external _ResultInt32Void trailingCase;
}

/// See the [Rust documentation for `TitlecaseOptions`](https://docs.rs/icu/2.2.0/icu/casemap/options/struct.TitlecaseOptions.html) for more information.
final class TitlecaseOptions {
  // ignore: public_member_api_docs
  LeadingAdjustment? leadingAdjustment;
  // ignore: public_member_api_docs
  TrailingCase? trailingCase;

  // This struct contains borrowed fields, so this takes in a list of
  // "edges" corresponding to where each lifetime's data may have been borrowed from
  // and passes it down to individual fields containing the borrow.
  // This method does not attempt to handle any dependencies between lifetimes, the caller
  // should handle this when constructing edge arrays.
  // ignore: unused_element
  TitlecaseOptions._fromFfi(_TitlecaseOptionsFfi ffi) :
    leadingAdjustment = ffi.leadingAdjustment.isOk ? LeadingAdjustment.values[ffi.leadingAdjustment.union.ok] : null,
    trailingCase = ffi.trailingCase.isOk ? TrailingCase.values[ffi.trailingCase.union.ok] : null;

  // ignore: unused_element
  _TitlecaseOptionsFfi _toFfi(ffi.Allocator temp) {
    final struct = ffi.Struct.create<_TitlecaseOptionsFfi>();
    final leadingAdjustment = this.leadingAdjustment;
    struct.leadingAdjustment = leadingAdjustment != null ? _ResultInt32Void.ok(leadingAdjustment.index) : _ResultInt32Void.err();
    final trailingCase = this.trailingCase;
    struct.trailingCase = trailingCase != null ? _ResultInt32Void.ok(trailingCase.index) : _ResultInt32Void.err();
    return struct;
  }

  /// See the [Rust documentation for `default`](https://docs.rs/icu/2.2.0/icu/casemap/options/struct.TitlecaseOptions.html#method.default) for more information.
  factory TitlecaseOptions({LeadingAdjustment? leadingAdjustment, TrailingCase? trailingCase}) {
    final result = _icu4x_TitlecaseOptionsV1_default_mv1();
    final dart = TitlecaseOptions._fromFfi(result);
    if (leadingAdjustment != null) {
      dart.leadingAdjustment = leadingAdjustment;
    }
    if (trailingCase != null) {
      dart.trailingCase = trailingCase;
    }
    return dart;
  }


  @override
  bool operator ==(Object other) =>
      other is TitlecaseOptions &&
      other.leadingAdjustment == leadingAdjustment &&
      other.trailingCase == trailingCase;

  @override
  int get hashCode => Object.hashAll([
        leadingAdjustment,
        trailingCase,
      ]);
}

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<_TitlecaseOptionsFfi Function()>(isLeaf: true, symbol: 'icu4x_TitlecaseOptionsV1_default_mv1')
// ignore: non_constant_identifier_names
external _TitlecaseOptionsFfi _icu4x_TitlecaseOptionsV1_default_mv1();

// dart format on
