Trait IntoDart

Source
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 &str

Source§

impl IntoDart for bool

Source§

impl IntoDart for char

Source§

impl IntoDart for f32

Source§

impl IntoDart for f64

Source§

impl IntoDart for i8

Source§

impl IntoDart for i16

Source§

impl IntoDart for i32

Source§

impl IntoDart for i64

Source§

impl IntoDart for i128

Source§

impl IntoDart for isize

Source§

impl IntoDart for u8

Source§

impl IntoDart for u16

Source§

impl IntoDart for u32

Source§

impl IntoDart for u64

Source§

impl IntoDart for u128

Source§

impl IntoDart for ()

Source§

impl IntoDart for usize

Source§

impl IntoDart for CString

Source§

impl IntoDart for String

Source§

impl IntoDart for Vec<f32>

Source§

impl IntoDart for Vec<f64>

Source§

impl IntoDart for Vec<i8>

Source§

impl IntoDart for Vec<i16>

Source§

impl IntoDart for Vec<i32>

Source§

impl IntoDart for Vec<i64>

Source§

impl IntoDart for Vec<isize>

Source§

impl IntoDart for Vec<u8>

Source§

impl IntoDart for Vec<u16>

Source§

impl IntoDart for Vec<u32>

Source§

impl IntoDart for Vec<u64>

Source§

impl IntoDart for Vec<usize>

Source§

impl IntoDart for Vec<DateTime<Local>>

Source§

impl IntoDart for Vec<DateTime<Utc>>

Source§

impl IntoDart for Vec<NaiveDate>

Source§

impl IntoDart for Vec<NaiveDateTime>

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 IntoDart for Vec<Duration>

Source§

impl IntoDart for Backtrace

Source§

impl IntoDart for HashSet<f32>

Source§

impl IntoDart for HashSet<f64>

Source§

impl IntoDart for HashSet<i8>

Source§

impl IntoDart for HashSet<i16>

Source§

impl IntoDart for HashSet<i32>

Source§

impl IntoDart for HashSet<i64>

Source§

impl IntoDart for HashSet<u8>

Source§

impl IntoDart for HashSet<u16>

Source§

impl IntoDart for HashSet<u32>

Source§

impl IntoDart for HashSet<u64>

Source§

impl IntoDart for Error

Source§

impl IntoDart for Backtrace

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 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 NaiveDate

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 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 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 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<A: IntoDart> IntoDart for (A,)

Source§

impl<A: IntoDart, B: IntoDart> IntoDart for (A, B)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart> IntoDart for (A, B, C)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart> IntoDart for (A, B, C, D)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart, E: IntoDart> IntoDart for (A, B, C, D, E)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart, E: IntoDart, F: IntoDart> IntoDart for (A, B, C, D, E, F)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart, E: IntoDart, F: IntoDart, G: IntoDart> IntoDart for (A, B, C, D, E, F, G)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart, E: IntoDart, F: IntoDart, G: IntoDart, H: IntoDart> IntoDart for (A, B, C, D, E, F, G, H)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart, E: IntoDart, F: IntoDart, G: IntoDart, H: IntoDart, I: IntoDart> IntoDart for (A, B, C, D, E, F, G, H, I)

Source§

impl<A: IntoDart, B: IntoDart, C: IntoDart, D: IntoDart, E: IntoDart, F: IntoDart, G: IntoDart, H: IntoDart, I: IntoDart, J: IntoDart> IntoDart for (A, B, C, D, E, F, G, H, I, J)

Source§

impl<K, V> IntoDart for HashMap<K, V>

Source§

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

Source§

impl<T> IntoDart for *const T

Source§

impl<T> IntoDart for *mut T

Source§

impl<T> IntoDart for Vec<T>

Source§

impl<T> IntoDart for HashSet<T>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl IntoDart for ZeroCopyBuffer<Vec<isize>>

Source§

impl IntoDart for ZeroCopyBuffer<Vec<usize>>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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