blob: 34b9d4cc6848c7d5bf7c4921e886c40cf4846cfd [file] [log] [blame] [edit]
// generated by diplomat-tool
part of 'lib.g.dart';
final class _CollatorOptionsFfi extends ffi.Struct {
@ffi.Int32()
external int strength;
@ffi.Int32()
external int alternateHandling;
@ffi.Int32()
external int caseFirst;
@ffi.Int32()
external int maxVariable;
@ffi.Int32()
external int caseLevel;
@ffi.Int32()
external int numeric;
@ffi.Int32()
external int backwardSecondLevel;
}
/// See the [Rust documentation for `CollatorOptions`](https://docs.rs/icu/latest/icu/collator/struct.CollatorOptions.html) for more information.
final class CollatorOptions {
CollatorStrength strength;
CollatorAlternateHandling alternateHandling;
CollatorCaseFirst caseFirst;
CollatorMaxVariable maxVariable;
CollatorCaseLevel caseLevel;
CollatorNumeric numeric;
CollatorBackwardSecondLevel backwardSecondLevel;
CollatorOptions(
{required this.strength,
required this.alternateHandling,
required this.caseFirst,
required this.maxVariable,
required this.caseLevel,
required this.numeric,
required this.backwardSecondLevel});
// 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 = CollatorStrength.values[ffi.strength],
alternateHandling =
CollatorAlternateHandling.values[ffi.alternateHandling],
caseFirst = CollatorCaseFirst.values[ffi.caseFirst],
maxVariable = CollatorMaxVariable.values[ffi.maxVariable],
caseLevel = CollatorCaseLevel.values[ffi.caseLevel],
numeric = CollatorNumeric.values[ffi.numeric],
backwardSecondLevel =
CollatorBackwardSecondLevel.values[ffi.backwardSecondLevel];
// ignore: unused_element
_CollatorOptionsFfi _toFfi(ffi.Allocator temp) {
final struct = ffi.Struct.create<_CollatorOptionsFfi>();
struct.strength = strength.index;
struct.alternateHandling = alternateHandling.index;
struct.caseFirst = caseFirst.index;
struct.maxVariable = maxVariable.index;
struct.caseLevel = caseLevel.index;
struct.numeric = numeric.index;
struct.backwardSecondLevel = backwardSecondLevel.index;
return struct;
}
@override
bool operator ==(Object other) =>
other is CollatorOptions &&
other.strength == strength &&
other.alternateHandling == alternateHandling &&
other.caseFirst == caseFirst &&
other.maxVariable == maxVariable &&
other.caseLevel == caseLevel &&
other.numeric == numeric &&
other.backwardSecondLevel == backwardSecondLevel;
@override
int get hashCode => Object.hashAll([
strength,
alternateHandling,
caseFirst,
maxVariable,
caseLevel,
numeric,
backwardSecondLevel,
]);
}