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

part of 'lib.g.dart';

final class _CollatorOptionsFfi extends ffi.Struct {
  external _ResultInt32Void strength;
  external _ResultInt32Void alternateHandling;
  external _ResultInt32Void maxVariable;
  external _ResultInt32Void caseLevel;
}

/// See the [Rust documentation for `CollatorOptions`](https://docs.rs/icu/2.2.0/icu/collator/options/struct.CollatorOptions.html) for more information.
final class CollatorOptions {
  // ignore: public_member_api_docs
  CollatorStrength? strength;
  // ignore: public_member_api_docs
  CollatorAlternateHandling? alternateHandling;
  // ignore: public_member_api_docs
  CollatorMaxVariable? maxVariable;
  // ignore: public_member_api_docs
  CollatorCaseLevel? caseLevel;

  // ignore: public_member_api_docs
  CollatorOptions({this.strength, this.alternateHandling, this.maxVariable, this.caseLevel});

  // 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
  CollatorOptions._fromFfi(_CollatorOptionsFfi ffi) :
    strength = ffi.strength.isOk ? CollatorStrength.values[ffi.strength.union.ok] : null,
    alternateHandling = ffi.alternateHandling.isOk ? CollatorAlternateHandling.values[ffi.alternateHandling.union.ok] : null,
    maxVariable = ffi.maxVariable.isOk ? CollatorMaxVariable.values[ffi.maxVariable.union.ok] : null,
    caseLevel = ffi.caseLevel.isOk ? CollatorCaseLevel.values[ffi.caseLevel.union.ok] : null;

  // ignore: unused_element
  _CollatorOptionsFfi _toFfi(ffi.Allocator temp) {
    final struct = ffi.Struct.create<_CollatorOptionsFfi>();
    final strength = this.strength;
    struct.strength = strength != null ? _ResultInt32Void.ok(strength.index) : _ResultInt32Void.err();
    final alternateHandling = this.alternateHandling;
    struct.alternateHandling = alternateHandling != null ? _ResultInt32Void.ok(alternateHandling.index) : _ResultInt32Void.err();
    final maxVariable = this.maxVariable;
    struct.maxVariable = maxVariable != null ? _ResultInt32Void.ok(maxVariable.index) : _ResultInt32Void.err();
    final caseLevel = this.caseLevel;
    struct.caseLevel = caseLevel != null ? _ResultInt32Void.ok(caseLevel.index) : _ResultInt32Void.err();
    return struct;
  }


  @override
  bool operator ==(Object other) =>
      other is CollatorOptions &&
      other.strength == strength &&
      other.alternateHandling == alternateHandling &&
      other.maxVariable == maxVariable &&
      other.caseLevel == caseLevel;

  @override
  int get hashCode => Object.hashAll([
        strength,
        alternateHandling,
        maxVariable,
        caseLevel,
      ]);
}

// dart format on
