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

part of 'lib.g.dart';

final class _LineBreakOptionsFfi extends ffi.Struct {
  external _ResultInt32Void strictness;
  external _ResultInt32Void wordOption;
}

/// See the [Rust documentation for `LineBreakOptions`](https://docs.rs/icu/2.2.0/icu/segmenter/options/struct.LineBreakOptions.html) for more information.
final class LineBreakOptions {
  // ignore: public_member_api_docs
  LineBreakStrictness? strictness;
  // ignore: public_member_api_docs
  LineBreakWordOption? wordOption;

  // ignore: public_member_api_docs
  LineBreakOptions({this.strictness, this.wordOption});

  // 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
  LineBreakOptions._fromFfi(_LineBreakOptionsFfi ffi) :
    strictness = ffi.strictness.isOk ? LineBreakStrictness.values[ffi.strictness.union.ok] : null,
    wordOption = ffi.wordOption.isOk ? LineBreakWordOption.values[ffi.wordOption.union.ok] : null;

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


  @override
  bool operator ==(Object other) =>
      other is LineBreakOptions &&
      other.strictness == strictness &&
      other.wordOption == wordOption;

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

// dart format on
