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

part of 'lib.g.dart';

final class _DisplayNamesOptionsFfi extends ffi.Struct {
  external _ResultInt32Void style;
  external _ResultInt32Void fallback;
  external _ResultInt32Void languageDisplay;
}

/// 🚧 This API is unstable and may experience breaking changes outside major releases.
///
/// See the [Rust documentation for `DisplayNamesOptions`](https://docs.rs/icu/2.2.0/icu/experimental/displaynames/struct.DisplayNamesOptions.html) for more information.
final class DisplayNamesOptions {
  // ignore: public_member_api_docs
  DisplayNamesStyle? style;
  // ignore: public_member_api_docs
  DisplayNamesFallback? fallback;
  // ignore: public_member_api_docs
  LanguageDisplay? languageDisplay;

  // ignore: public_member_api_docs
  DisplayNamesOptions({this.style, this.fallback, this.languageDisplay});

  // 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
  DisplayNamesOptions._fromFfi(_DisplayNamesOptionsFfi ffi) :
    style = ffi.style.isOk ? DisplayNamesStyle.values[ffi.style.union.ok] : null,
    fallback = ffi.fallback.isOk ? DisplayNamesFallback.values[ffi.fallback.union.ok] : null,
    languageDisplay = ffi.languageDisplay.isOk ? LanguageDisplay.values[ffi.languageDisplay.union.ok] : null;

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


  @override
  bool operator ==(Object other) =>
      other is DisplayNamesOptions &&
      other.style == style &&
      other.fallback == fallback &&
      other.languageDisplay == languageDisplay;

  @override
  int get hashCode => Object.hashAll([
        style,
        fallback,
        languageDisplay,
      ]);
}

// dart format on
