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§
Sourcefn into_dart(self) -> DartCObject
fn into_dart(self) -> DartCObject
Consumes Self and Performs the conversion.
Implementations on Foreign Types§
Source§impl IntoDart for Vec<f32>
Available on crate feature zero-copy only.
impl IntoDart for Vec<f32>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<f64>
Available on crate feature zero-copy only.
impl IntoDart for Vec<f64>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<i8>
Available on crate feature zero-copy only.
impl IntoDart for Vec<i8>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<i16>
Available on crate feature zero-copy only.
impl IntoDart for Vec<i16>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<i32>
Available on crate feature zero-copy only.
impl IntoDart for Vec<i32>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<i64>
Available on crate feature zero-copy only.
impl IntoDart for Vec<i64>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<u8>
Available on crate feature zero-copy only.
impl IntoDart for Vec<u8>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<u16>
Available on crate feature zero-copy only.
impl IntoDart for Vec<u16>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<u32>
Available on crate feature zero-copy only.
impl IntoDart for Vec<u32>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<u64>
Available on crate feature zero-copy only.
impl IntoDart for Vec<u64>
zero-copy only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<NaiveDateTime>
impl IntoDart for Vec<NaiveDateTime>
fn into_dart(self) -> DartCObject
Source§impl IntoDart for Vec<Uuid>
impl IntoDart for Vec<Uuid>
Source§fn into_dart(self) -> DartCObject
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 Error
Available on crate feature anyhow only.
impl IntoDart for Error
anyhow only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for Backtrace
Available on crate feature backtrace only.
impl IntoDart for Backtrace
backtrace only.fn into_dart(self) -> DartCObject
Source§impl IntoDart for DateTime<Local>
impl IntoDart for DateTime<Local>
Source§fn into_dart(self) -> DartCObject
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>
impl IntoDart for DateTime<Utc>
Source§fn into_dart(self) -> DartCObject
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
impl IntoDart for NaiveDate
Source§fn into_dart(self) -> DartCObject
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
impl IntoDart for NaiveDateTime
Source§fn into_dart(self) -> DartCObject
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
impl IntoDart for Uuid
Source§fn into_dart(self) -> DartCObject
fn into_dart(self) -> DartCObject
delegate to Vec<u8> implementation
on the other side of FFI, value should be reconstructed like: