| // generated by diplomat-tool |
| // dart format off |
| |
| part of 'lib.g.dart'; |
| |
| final class _IsoDateTimeFfi extends ffi.Struct { |
| external ffi.Pointer<ffi.Opaque> date; |
| external ffi.Pointer<ffi.Opaque> time; |
| } |
| |
| /// An ICU4X DateTime object capable of containing a ISO-8601 date and time. |
| /// |
| /// See the [Rust documentation for `DateTime`](https://docs.rs/icu/2.0.0/icu/time/struct.DateTime.html) for more information. |
| final class IsoDateTime { |
| final IsoDate date; |
| final Time time; |
| |
| // 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 |
| IsoDateTime._fromFfi(_IsoDateTimeFfi ffi) : |
| date = IsoDate._fromFfi(ffi.date, []), |
| time = Time._fromFfi(ffi.time, []); |
| |
| // ignore: unused_element |
| _IsoDateTimeFfi _toFfi(ffi.Allocator temp) { |
| final struct = ffi.Struct.create<_IsoDateTimeFfi>(); |
| struct.date = date._ffi; |
| struct.time = time._ffi; |
| return struct; |
| } |
| |
| /// Creates a new [IsoDateTime] from an IXDTF string. |
| /// |
| /// See the [Rust documentation for `try_from_str`](https://docs.rs/icu/2.0.0/icu/time/struct.DateTime.html#method.try_from_str) for more information. |
| /// |
| /// Throws [Rfc9557ParseError] on failure. |
| factory IsoDateTime.fromString(String v) { |
| final temp = _FinalizedArena(); |
| final result = _icu4x_IsoDateTime_from_string_mv1(v._utf8AllocIn(temp.arena)); |
| if (!result.isOk) { |
| throw Rfc9557ParseError.values[result.union.err]; |
| } |
| return IsoDateTime._fromFfi(result.union.ok); |
| } |
| |
| |
| @override |
| bool operator ==(Object other) => |
| other is IsoDateTime && |
| other.date == date && |
| other.time == time; |
| |
| @override |
| int get hashCode => Object.hashAll([ |
| date, |
| time, |
| ]); |
| } |
| |
| @_DiplomatFfiUse('icu4x_IsoDateTime_from_string_mv1') |
| @ffi.Native<_ResultIsoDateTimeFfiInt32 Function(_SliceUtf8)>(isLeaf: true, symbol: 'icu4x_IsoDateTime_from_string_mv1') |
| // ignore: non_constant_identifier_names |
| external _ResultIsoDateTimeFfiInt32 _icu4x_IsoDateTime_from_string_mv1(_SliceUtf8 v); |
| |
| // dart format on |