pub trait IntoDart {
    // Required method
    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§

source

fn into_dart(self) -> DartCObject

Consumes Self and Performs the conversion.

Implementations on Foreign Types§

source§

impl IntoDart for i16

source§

impl IntoDart for i8

source§

impl IntoDart for Vec<i8>

source§

impl IntoDart for DateTime<Utc>

source§

fn into_dart(self) -> DartCObject

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

source§

impl IntoDart for bool

source§

impl IntoDart for Uuid

source§

fn into_dart(self) -> DartCObject

delegate to Vec<u8> implementation

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

  • hydrate into Dart UuidValue UuidValue.fromByteList(raw);

  • hydrate into Rust Uuid

    uuid::Uuid::from_bytes(*<&[u8] as std::convert::TryInto<&[u8;16]>>::try_into(raw.as_slice()).expect("invalid uuid slice"));
source§

impl<const N: usize> IntoDart for [i16; N]

source§

impl IntoDart for Vec<Duration>

source§

impl<const N: usize> IntoDart for [f32; N]

source§

impl IntoDart for Vec<Uuid>

source§

fn into_dart(self) -> DartCObject

⚠️ concatenated in a single Vec<u8> for performance optimization

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

  • hydrate into Dart List<UuidValue>

    return List<UuidValue>.generate(
      raw.lengthInBytes / 16,
      (int i) => UuidValue.fromByteList(Uint8List.view(raw.buffer, i * 16, 16)),
      growable: false);
    
  • hydrate into Rust Vec<Uuid>

    raw
    .as_slice()
    .chunks(16)
    .map(|x: &[u8]| uuid::Uuid::from_bytes(*<&[u8] as std::convert::TryInto<&[u8;16]>>::try_into(x).expect("invalid uuid slice")))
    .collect();

note that buffer could end up being incomplete under the same conditions as of std::io::Write::write.

source§

impl<const N: usize> IntoDart for [i32; N]

source§

impl<const N: usize> IntoDart for [NaiveDateTime; N]

source§

impl IntoDart for ()

source§

impl<const N: usize> IntoDart for [i8; N]

source§

impl IntoDart for u16

source§

impl IntoDart for Backtrace

source§

impl IntoDart for usize

source§

impl IntoDart for Duration

source§

fn into_dart(self) -> DartCObject

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);

source§

impl<const N: usize> IntoDart for [DateTime<Local>; N]

source§

impl IntoDart for NaiveDateTime

source§

fn into_dart(self) -> DartCObject

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

source§

impl<T> IntoDart for Vec<T>where T: IntoDartExceptPrimitive,

source§

impl IntoDart for Vec<u32>

source§

impl IntoDart for DateTime<Local>

source§

fn into_dart(self) -> DartCObject

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

source§

impl IntoDart for char

source§

impl IntoDart for Vec<f32>

source§

impl IntoDart for Vec<i16>

source§

impl<const N: usize> IntoDart for [u8; N]

source§

impl<T, const N: usize> IntoDart for [T; N]where T: IntoDartExceptPrimitive,

source§

impl<const N: usize> IntoDart for [u16; N]

source§

impl IntoDart for Vec<u8>

source§

impl<const N: usize> IntoDart for [Uuid; N]

source§

impl<const N: usize> IntoDart for [i64; N]

source§

impl<const N: usize> IntoDart for [u64; N]

source§

impl IntoDart for Vec<u64>

source§

impl IntoDart for Error

source§

impl IntoDart for CString

source§

impl IntoDart for &str

source§

impl IntoDart for String

source§

impl IntoDart for Vec<i32>

source§

impl<T> IntoDart for Option<T>where T: IntoDart,

source§

impl<const N: usize> IntoDart for [u32; N]

source§

impl<const N: usize> IntoDart for [f64; N]

source§

impl IntoDart for u32

source§

impl IntoDart for Vec<f64>

source§

impl IntoDart for Vec<NaiveDateTime>

source§

impl IntoDart for Vec<u16>

source§

impl IntoDart for u64

source§

impl IntoDart for i128

source§

impl IntoDart for Vec<DateTime<Utc>>

source§

impl IntoDart for f32

source§

impl IntoDart for u8

source§

impl<const N: usize> IntoDart for [DateTime<Utc>; N]

source§

impl IntoDart for u128

source§

impl IntoDart for Vec<DateTime<Local>>

source§

impl<T> IntoDart for *const T

source§

impl IntoDart for Vec<i64>

source§

impl IntoDart for i64

source§

impl IntoDart for f64

source§

impl<const N: usize> IntoDart for [Duration; N]

source§

impl IntoDart for i32

source§

impl<T, E> IntoDart for Result<T, E>where T: IntoDart, E: ToString,

source§

impl<T> IntoDart for *mut T

Implementors§

source§

impl<T> IntoDart for ZeroCopyBuffer<Vec<T>>where T: DartTypedDataTypeTrait,

source§

impl<T> IntoDart for Twhere T: Into<DartCObject>,

source§

impl<T, const N: usize> IntoDart for ZeroCopyBuffer<[T; N]>where T: DartTypedDataTypeTrait,