blob: 9fffd546f9621300d2d61b9296d27b800b86865f [file]
// generated by diplomat-tool
// dart format off
part of 'lib.g.dart';
/// See the [Rust documentation for `TimeZone`](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZone.html) for more information.
final class TimeZone 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.
TimeZone._fromFfi(this._ffi, this._selfEdge) {
if (_selfEdge.isEmpty) {
_finalizer.attach(this, _ffi.cast());
}
}
@_DiplomatFfiUse('icu4x_TimeZone_destroy_mv1')
static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_TimeZone_destroy_mv1));
/// The unknown time zone.
///
/// See the [Rust documentation for `unknown`](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZoneInfo.html#method.unknown) for more information.
factory TimeZone.unknown() {
final result = _icu4x_TimeZone_unknown_mv1();
return TimeZone._fromFfi(result, []);
}
/// Whether the time zone is the unknown zone.
///
/// See the [Rust documentation for `is_unknown`](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZone.html#method.is_unknown) for more information.
bool isUnknown() {
final result = _icu4x_TimeZone_is_unknown_mv1(_ffi);
return result;
}
/// Creates a time zone from a BCP-47 string.
///
/// Returns the unknown time zone if the string is not a valid BCP-47 subtag.
///
/// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZone.html)
factory TimeZone.fromBcp47(String id) {
final temp = _FinalizedArena();
final result = _icu4x_TimeZone_create_from_bcp47_mv1(id._utf8AllocIn(temp.arena));
return TimeZone._fromFfi(result, []);
}
/// See the [Rust documentation for `with_offset`](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZone.html#method.with_offset) for more information.
TimeZoneInfo withOffset(UtcOffset offset) {
final result = _icu4x_TimeZone_with_offset_mv1(_ffi, offset._ffi);
return TimeZoneInfo._fromFfi(result, []);
}
/// See the [Rust documentation for `without_offset`](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZone.html#method.without_offset) for more information.
TimeZoneInfo withoutOffset() {
final result = _icu4x_TimeZone_without_offset_mv1(_ffi);
return TimeZoneInfo._fromFfi(result, []);
}
}
@_DiplomatFfiUse('icu4x_TimeZone_destroy_mv1')
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(isLeaf: true, symbol: 'icu4x_TimeZone_destroy_mv1')
// ignore: non_constant_identifier_names
external void _icu4x_TimeZone_destroy_mv1(ffi.Pointer<ffi.Void> self);
@_DiplomatFfiUse('icu4x_TimeZone_unknown_mv1')
@ffi.Native<ffi.Pointer<ffi.Opaque> Function()>(isLeaf: true, symbol: 'icu4x_TimeZone_unknown_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZone_unknown_mv1();
@_DiplomatFfiUse('icu4x_TimeZone_is_unknown_mv1')
@ffi.Native<ffi.Bool Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZone_is_unknown_mv1')
// ignore: non_constant_identifier_names
external bool _icu4x_TimeZone_is_unknown_mv1(ffi.Pointer<ffi.Opaque> self);
@_DiplomatFfiUse('icu4x_TimeZone_create_from_bcp47_mv1')
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(_SliceUtf8)>(isLeaf: true, symbol: 'icu4x_TimeZone_create_from_bcp47_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZone_create_from_bcp47_mv1(_SliceUtf8 id);
@_DiplomatFfiUse('icu4x_TimeZone_with_offset_mv1')
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>, ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZone_with_offset_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZone_with_offset_mv1(ffi.Pointer<ffi.Opaque> self, ffi.Pointer<ffi.Opaque> offset);
@_DiplomatFfiUse('icu4x_TimeZone_without_offset_mv1')
@ffi.Native<ffi.Pointer<ffi.Opaque> Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_TimeZone_without_offset_mv1')
// ignore: non_constant_identifier_names
external ffi.Pointer<ffi.Opaque> _icu4x_TimeZone_without_offset_mv1(ffi.Pointer<ffi.Opaque> self);
// dart format on