pub trait IntoDart {
    fn into_dart(self) -> DartCObject;
}
Expand description

A trait to convert between Rust types and Dart Types that could then be sent to the isolate

see: crate::Isolate::post

Required Methods§

Consumes Self and Performs the conversion.

Implementations on Foreign Types§

on the other side of FFI, value should be reconstructed like:

  • hydrate into Dart DateTime DateTime.fromMicrosecondsSinceEpoch(raw, isUtc: true);

  • hydrate into Rust NaiveDateTime

    let s = (raw / 1_000_000) as i64;
    let ns = (raw.rem_euclid(1_000_000) * 1_000) as u32;
    chrono::NaiveDateTime::from_timestamp(s, ns)

    note that it could overflow under the same conditions as of chrono::NaiveDateTime::from_timestamp

on the other side of FFI, value should be reconstructed like:

  • hydrate into Dart DateTime DateTime.fromMicrosecondsSinceEpoch(raw, isUtc: false);

  • hydrate into Rust DateTime::<Local>

    let s = (raw / 1_000_000) as i64;
    let ns = (raw.rem_euclid(1_000_000) * 1_000) as u32;
    chrono::DateTime::<chrono::Local>::from(
      chrono::DateTime::<chrono::Utc>::from_utc(
        chrono::NaiveDateTime::from_timestamp(s, ns), chrono::Utc));

    note that it could overflow under the same conditions as of chrono::NaiveDateTime::from_timestamp

A workaround to send raw pointers to dart over the port. it will be sent as int64 on 64bit targets, and as int32 on 32bit targets.

on the other side of FFI, value should be reconstructed like:

  • hydrate into Dart Duration Duration(microseconds: raw);

  • hydrate into Rust Duration chrono::Duration::microseconds(raw);

on the other side of FFI, value should be reconstructed like:

  • hydrate into Dart DateTime DateTime.fromMicrosecondsSinceEpoch(raw, isUtc: true);

  • hydrate into Rust DateTime::<Utc>

    let s = (raw / 1_000_000) as i64;
    let ns = (raw.rem_euclid(1_000_000) * 1_000) as u32;
    chrono::DateTime::<chrono::Utc>::from_utc(
      chrono::NaiveDateTime::from_timestamp(s, ns), chrono::Utc);

    note that it could overflow under the same conditions as of chrono::NaiveDateTime::from_timestamp

Implementors§