Replies: 1 comment 4 replies
-
IMHO we can generate the Btw for a duration: Looking at DateTime's source code, it is implemented as:
Maybe we do not need to do that hard! Just convert it to |
Beta Was this translation helpful? Give feedback.
-
Hi, I would like to provide the necessary to allow for sending e.g.
chrono::DateTime<chrono::Utc>
over FFI.I'm stuck at the moment, below are the steps I already followed :
opening a PR
I first considered contributing directly to
flutter_rust_bridge
, since aDateTime<Utc>
inherently all boils down to ai64
, but changed my mind when browsingchrono
's documentation since there's considerations about the aforementionedi64
being a timestamp in seconds / milliseconds / microseconds / nanoseconds ? And probably different users have different requirements.manually code-generating
So, naturally I then came to mimic the code generator by basically writing the boilerplate by hand, implementing
Wire2Api<T>
, creatingwire_DateTimeUtc
, etc. Which quickly turns into a dead-end since I shouldn't touch any generated file (e.g. to add required methods inbridge_generated.dart
toclass NativeImpl extends FlutterRustBridgeBase<NativeWire> implements Native
). Then I wondered maybe dart code would in fact be auto-generated, but of course I got caught by the compiler sinceDateTime<Utc>
is an external type.mirroring
Which of course led me to try to provide a wrapper to
DateTime<Utc>
with#[frb(mirror)]
annotation.Here I also faced a dead-end since at its deepest,
DateTime<Utc>
contains an internal unexposed struct, namelyDateImpl
.To be honest, I'm running out of ideas. Is there an idiomatic way to do it ?
So far I create intermediate structs all over the place (converting
DateTime<Utc>
to e.g. a RFC3339 compliantString
) but it's a bit cumbersome.Beta Was this translation helpful? Give feedback.
All reactions