| // generated by diplomat-tool |
| // dart format off |
| |
| part of 'lib.g.dart'; |
| |
| /// See the [Rust documentation for `UtcOffset`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) for more information. |
| final class UtcOffset 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. |
| UtcOffset._fromFfi(this._ffi, this._selfEdge) { |
| if (_selfEdge.isEmpty) { |
| _finalizer.attach(this, _ffi.cast()); |
| } |
| } |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_destroy_mv1') |
| static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_UtcOffset_destroy_mv1)); |
| |
| /// Creates an offset from seconds. |
| /// |
| /// Errors if the offset seconds are out of range. |
| /// |
| /// See the [Rust documentation for `try_from_seconds`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.try_from_seconds) for more information. |
| /// |
| /// Throws [TimeZoneInvalidOffsetError] on failure. |
| factory UtcOffset.fromSeconds(int seconds) { |
| final result = _icu4x_UtcOffset_from_seconds_mv1(seconds); |
| if (!result.isOk) { |
| throw TimeZoneInvalidOffsetError(); |
| } |
| return UtcOffset._fromFfi(result.union.ok, []); |
| } |
| |
| /// Creates an offset from a string. |
| /// |
| /// See the [Rust documentation for `try_from_str`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.try_from_str) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| /// |
| /// Throws [TimeZoneInvalidOffsetError] on failure. |
| factory UtcOffset.fromString(String offset) { |
| final temp = _FinalizedArena(); |
| final result = _icu4x_UtcOffset_from_string_mv1(offset._utf8AllocIn(temp.arena)); |
| if (!result.isOk) { |
| throw TimeZoneInvalidOffsetError(); |
| } |
| return UtcOffset._fromFfi(result.union.ok, []); |
| } |
| |
| /// Returns the value as offset seconds. |
| /// |
| /// See the [Rust documentation for `offset`](https://docs.rs/icu/2.0.0/icu/time/struct.TimeZoneInfo.html#method.offset) for more information. |
| /// |
| /// See the [Rust documentation for `to_seconds`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.to_seconds) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| int get seconds { |
| final result = _icu4x_UtcOffset_seconds_mv1(_ffi); |
| return result; |
| } |
| |
| /// Returns whether the offset is positive. |
| /// |
| /// See the [Rust documentation for `is_non_negative`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.is_non_negative) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| bool get isNonNegative { |
| final result = _icu4x_UtcOffset_is_non_negative_mv1(_ffi); |
| return result; |
| } |
| |
| /// Returns whether the offset is zero. |
| /// |
| /// See the [Rust documentation for `is_zero`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.is_zero) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| bool get isZero { |
| final result = _icu4x_UtcOffset_is_zero_mv1(_ffi); |
| return result; |
| } |
| |
| /// Returns the hours part of the offset. |
| /// |
| /// See the [Rust documentation for `hours_part`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.hours_part) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| int get hoursPart { |
| final result = _icu4x_UtcOffset_hours_part_mv1(_ffi); |
| return result; |
| } |
| |
| /// Returns the minutes part of the offset. |
| /// |
| /// See the [Rust documentation for `minutes_part`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.minutes_part) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| int get minutesPart { |
| final result = _icu4x_UtcOffset_minutes_part_mv1(_ffi); |
| return result; |
| } |
| |
| /// Returns the seconds part of the offset. |
| /// |
| /// See the [Rust documentation for `seconds_part`](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html#method.seconds_part) for more information. |
| /// |
| /// Additional information: [1](https://docs.rs/icu/2.0.0/icu/time/zone/struct.UtcOffset.html) |
| int get secondsPart { |
| final result = _icu4x_UtcOffset_seconds_part_mv1(_ffi); |
| return result; |
| } |
| |
| } |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_destroy_mv1') |
| @ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_destroy_mv1') |
| // ignore: non_constant_identifier_names |
| external void _icu4x_UtcOffset_destroy_mv1(ffi.Pointer<ffi.Void> self); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_from_seconds_mv1') |
| @ffi.Native<_ResultOpaqueTimeZoneInvalidOffsetErrorFfi Function(ffi.Int32)>(isLeaf: true, symbol: 'icu4x_UtcOffset_from_seconds_mv1') |
| // ignore: non_constant_identifier_names |
| external _ResultOpaqueTimeZoneInvalidOffsetErrorFfi _icu4x_UtcOffset_from_seconds_mv1(int seconds); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_from_string_mv1') |
| @ffi.Native<_ResultOpaqueTimeZoneInvalidOffsetErrorFfi Function(_SliceUtf8)>(isLeaf: true, symbol: 'icu4x_UtcOffset_from_string_mv1') |
| // ignore: non_constant_identifier_names |
| external _ResultOpaqueTimeZoneInvalidOffsetErrorFfi _icu4x_UtcOffset_from_string_mv1(_SliceUtf8 offset); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_seconds_mv1') |
| @ffi.Native<ffi.Int32 Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_seconds_mv1') |
| // ignore: non_constant_identifier_names |
| external int _icu4x_UtcOffset_seconds_mv1(ffi.Pointer<ffi.Opaque> self); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_is_non_negative_mv1') |
| @ffi.Native<ffi.Bool Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_is_non_negative_mv1') |
| // ignore: non_constant_identifier_names |
| external bool _icu4x_UtcOffset_is_non_negative_mv1(ffi.Pointer<ffi.Opaque> self); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_is_zero_mv1') |
| @ffi.Native<ffi.Bool Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_is_zero_mv1') |
| // ignore: non_constant_identifier_names |
| external bool _icu4x_UtcOffset_is_zero_mv1(ffi.Pointer<ffi.Opaque> self); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_hours_part_mv1') |
| @ffi.Native<ffi.Int32 Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_hours_part_mv1') |
| // ignore: non_constant_identifier_names |
| external int _icu4x_UtcOffset_hours_part_mv1(ffi.Pointer<ffi.Opaque> self); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_minutes_part_mv1') |
| @ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_minutes_part_mv1') |
| // ignore: non_constant_identifier_names |
| external int _icu4x_UtcOffset_minutes_part_mv1(ffi.Pointer<ffi.Opaque> self); |
| |
| @_DiplomatFfiUse('icu4x_UtcOffset_seconds_part_mv1') |
| @ffi.Native<ffi.Uint32 Function(ffi.Pointer<ffi.Opaque>)>(isLeaf: true, symbol: 'icu4x_UtcOffset_seconds_part_mv1') |
| // ignore: non_constant_identifier_names |
| external int _icu4x_UtcOffset_seconds_part_mv1(ffi.Pointer<ffi.Opaque> self); |
| |
| // dart format on |