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

part of 'lib.g.dart';

/// See the [Rust documentation for `TimeZoneInfo`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html) for more information.
final class TimeZoneInfo implements ffi.Finalizable {
  final ffi.Pointer<ffi.Opaque> _ffi;

  // These are "used" in the sense that they keep dependencies alive
  // ignore: unused_field
  final core.List<Object> _selfEdge;

  // This takes in a list of lifetime edges (including for &self borrows)
  // corresponding to data this may borrow from. These should be flat arrays containing
  // references to objects, and this object will hold on to them to keep them alive and
  // maintain borrow validity.
  TimeZoneInfo._fromFfi(this._ffi, this._selfEdge) {
    if (_selfEdge.isEmpty) {
      _icu4x_TimeZoneInfo_destroy_mv1(this, _ffi.cast());
    }
  }

  // ignore: experimental_member_use
  @meta.RecordUse()
  // ignore: non_constant_identifier_names
  static void _icu4x_TimeZoneInfo_destroy_mv1(TimeZoneInfo cl, ffi.Pointer<ffi.Void> pointer) => _finalizer.attach(cl, pointer);

  static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_internal_icu4x_TimeZoneInfo_destroy_mv1));

  /// Creates a time zone for UTC (Coordinated Universal Time).
  ///
  /// See the [Rust documentation for `utc`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.utc) for more information.
  factory TimeZoneInfo.utc() {
    final result = _icu4x_TimeZoneInfo_utc_mv1();
    return TimeZoneInfo._fromFfi(result, []);
  }

  /// See the [Rust documentation for `id`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.id) for more information.
  TimeZone get id {
    final result = _icu4x_TimeZoneInfo_id_mv1(_ffi);
    return TimeZone._fromFfi(result, []);
  }

  /// Sets the datetime at which to interpret the time zone
  /// for display name lookup.
  ///
  /// Notes:
  ///
  /// - If not set, the formatting datetime is used if possible.
  /// - If the offset is not set, the datetime is interpreted as UTC.
  /// - The constraints are the same as with `ZoneNameTimestamp` in Rust.
  /// - Set to year 1000 or 9999 for a reference far in the past or future.
  ///
  /// See the [Rust documentation for `at_date_time`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.at_date_time) for more information.
  ///
  /// Additional information: [1](https://docs.rs/icu/2.2.0/icu/time/zone/struct.ZoneNameTimestamp.html)
  TimeZoneInfo atDateTimeIso(IsoDate date, Time time) {
    final result = _icu4x_TimeZoneInfo_at_date_time_iso_mv1(_ffi, date._ffi, time._ffi);
    return TimeZoneInfo._fromFfi(result, []);
  }

  /// Sets the datetime at which to interpret the time zone
  /// for display name lookup.
  ///
  /// Notes:
  ///
  /// - If not set, the formatting datetime is used if possible.
  /// - If the offset is not set, the datetime is interpreted as UTC.
  /// - The constraints are the same as with `ZoneNameTimestamp` in Rust.
  /// - Set to year 1000 or 9999 for a reference far in the past or future.
  ///
  /// See the [Rust documentation for `at_date_time`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.at_date_time) for more information.
  ///
  /// Additional information: [1](https://docs.rs/icu/2.2.0/icu/time/zone/struct.ZoneNameTimestamp.html)
  TimeZoneInfo atDateTime(Date date, Time time) {
    final result = _icu4x_TimeZoneInfo_at_date_time_mv1(_ffi, date._ffi, time._ffi);
    return TimeZoneInfo._fromFfi(result, []);
  }

  /// Sets the timestamp, in milliseconds since Unix epoch, at which to interpret the time zone
  /// for display name lookup.
  ///
  /// Notes:
  ///
  /// - If not set, the formatting datetime is used if possible.
  /// - The constraints are the same as with `ZoneNameTimestamp` in Rust.
  ///
  /// See the [Rust documentation for `with_zone_name_timestamp`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.with_zone_name_timestamp) for more information.
  ///
  /// Additional information: [1](https://docs.rs/icu/2.2.0/icu/time/zone/struct.ZoneNameTimestamp.html#method.from_epoch_seconds)
  TimeZoneInfo atTimestamp(int timestamp) {
    final result = _icu4x_TimeZoneInfo_at_timestamp_mv1(_ffi, timestamp);
    return TimeZoneInfo._fromFfi(result, []);
  }

  /// Returns the `DateTime` for the UTC zone name reference time
  ///
  /// See the [Rust documentation for `zone_name_timestamp`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.zone_name_timestamp) for more information.
  IsoDateTime? get zoneNameDateTime {
    final result = _icu4x_TimeZoneInfo_zone_name_date_time_mv1(_ffi);
    if (!result.isOk) {
      return null;
    }
    return IsoDateTime._fromFfi(result.union.ok);
  }

  /// See the [Rust documentation for `offset`](https://docs.rs/icu/2.2.0/icu/time/struct.TimeZoneInfo.html#method.offset) for more information.
  UtcOffset? get offset {
    final result = _icu4x_TimeZoneInfo_offset_mv1(_ffi);
    return result.address == 0 ? null : UtcOffset._fromFfi(result, []);
  }

}

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_destroy_mv1')
// ignore: non_constant_identifier_names
external void _internal_icu4x_TimeZoneInfo_destroy_mv1(ffi.Pointer<ffi.Void> self);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function()>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_utc_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZoneInfo_utc_mv1();

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_id_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZoneInfo_id_mv1(ffi.Pointer<ffi.Opaque> self);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_at_date_time_iso_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZoneInfo_at_date_time_iso_mv1(ffi.Pointer<ffi.Opaque> self, ffi.Pointer<ffi.Opaque> date, ffi.Pointer<ffi.Opaque> time);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_at_date_time_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZoneInfo_at_date_time_mv1(ffi.Pointer<ffi.Opaque> self, ffi.Pointer<ffi.Opaque> date, ffi.Pointer<ffi.Opaque> time);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>, ffi.Int64)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_at_timestamp_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZoneInfo_at_timestamp_mv1(ffi.Pointer<ffi.Opaque> self, int timestamp);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<_ResultIsoDateTimeFfiVoid Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_zone_name_date_time_mv1')
// ignore: non_constant_identifier_names
external _ResultIsoDateTimeFfiVoid _icu4x_TimeZoneInfo_zone_name_date_time_mv1(ffi.Pointer<ffi.Opaque> self);

// ignore: experimental_member_use
@meta.RecordUse()
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_offset_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZoneInfo_offset_mv1(ffi.Pointer<ffi.Opaque> self);

// dart format on
