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

part of 'lib.g.dart';

final class _ZonedIsoDateTimeFfi extends ffi.Struct {
  external ffi.Pointer<ffi.Opaque> date;
  external ffi.Pointer<ffi.Opaque> time;
  external ffi.Pointer<ffi.Opaque> zone;
}

/// An ICU4X `ZonedDateTime` object capable of containing a ISO-8601 date, time, and zone.
///
/// See the [Rust documentation for `ZonedDateTime`](https://docs.rs/icu/2.2.0/icu/time/struct.ZonedDateTime.html) for more information.
final class ZonedIsoDateTime {
  // ignore: public_member_api_docs
  final IsoDate date;
  // ignore: public_member_api_docs
  final Time time;
  // ignore: public_member_api_docs
  final TimeZoneInfo zone;

  // 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
  ZonedIsoDateTime._fromFfi(_ZonedIsoDateTimeFfi ffi) :
    date = IsoDate._fromFfi(ffi.date, []),
    time = Time._fromFfi(ffi.time, []),
    zone = TimeZoneInfo._fromFfi(ffi.zone, []);

  // ignore: unused_element
  _ZonedIsoDateTimeFfi _toFfi(ffi.Allocator temp) {
    final struct = ffi.Struct.create<_ZonedIsoDateTimeFfi>();
    struct.date = date._ffi;
    struct.time = time._ffi;
    struct.zone = zone._ffi;
    return struct;
  }

  /// Creates a new [ZonedIsoDateTime] from an IXDTF string.
  ///
  /// See the [Rust documentation for `try_strict_from_str`](https://docs.rs/icu/2.2.0/icu/time/struct.ZonedDateTime.html#method.try_strict_from_str) for more information.
  ///
  /// Throws [Rfc9557ParseError] on failure.
  factory ZonedIsoDateTime.strictFromString(String v, IanaParser ianaParser) {
    final temp = _FinalizedArena();
    final result = _icu4x_ZonedIsoDateTime_strict_from_string_mv1(v._utf8AllocIn(temp.arena), ianaParser._ffi);
    if (!result.isOk) {
      throw Rfc9557ParseError.values[result.union.err];
    }
    return ZonedIsoDateTime._fromFfi(result.union.ok);
  }

  /// Creates a new [ZonedIsoDateTime] from milliseconds since epoch (timestamp) and a UTC offset.
  ///
  /// Note: [ZonedIsoDateTime]s created with this constructor can only be formatted using localized offset zone styles.
  ///
  /// See the [Rust documentation for `from_epoch_milliseconds_and_utc_offset`](https://docs.rs/icu/2.2.0/icu/time/struct.ZonedDateTime.html#method.from_epoch_milliseconds_and_utc_offset) for more information.
  factory ZonedIsoDateTime.fromEpochMillisecondsAndUtcOffset(int epochMilliseconds, UtcOffset utcOffset) {
    final result = _icu4x_ZonedIsoDateTime_from_epoch_milliseconds_and_utc_offset_mv1(epochMilliseconds, utcOffset._ffi);
    return ZonedIsoDateTime._fromFfi(result);
  }


  @override
  bool operator ==(Object other) =>
      other is ZonedIsoDateTime &&
      other.date == date &&
      other.time == time &&
      other.zone == zone;

  @override
  int get hashCode => Object.hashAll([
        date,
        time,
        zone,
      ]);
}

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<_ResultZonedIsoDateTimeFfiInt32 Function(_SliceUtf8, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_ZonedIsoDateTime_strict_from_string_mv1')
// ignore: non_constant_identifier_names
external _ResultZonedIsoDateTimeFfiInt32 _icu4x_ZonedIsoDateTime_strict_from_string_mv1(_SliceUtf8 v, ffi.Pointer<ffi.Opaque> ianaParser);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<_ZonedIsoDateTimeFfi Function(ffi.Int64, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_ZonedIsoDateTime_from_epoch_milliseconds_and_utc_offset_mv1')
// ignore: non_constant_identifier_names
external _ZonedIsoDateTimeFfi _icu4x_ZonedIsoDateTime_from_epoch_milliseconds_and_utc_offset_mv1(int epochMilliseconds, ffi.Pointer<ffi.Opaque> utcOffset);

// dart format on
