Trait flutter_rust_bridge::ffi::io::IntoDart
source · 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§
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<NaiveDateTime, Global>
impl IntoDart for Vec<NaiveDateTime, Global>
fn into_dart(self) -> DartCObject
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<T, const N: usize> IntoDart for [T; N]where
T: IntoDartExceptPrimitive,
impl<T, const N: usize> IntoDart for [T; N]where
T: IntoDartExceptPrimitive,
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<const N: usize> IntoDart for [DateTime<Local>; N]
impl<const N: usize> IntoDart for [DateTime<Local>; N]
fn into_dart(self) -> DartCObject
source§impl<T> IntoDart for *const T
impl<T> IntoDart for *const T
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.
fn into_dart(self) -> DartCObject
source§impl<const N: usize> IntoDart for [NaiveDateTime; N]
impl<const N: usize> IntoDart for [NaiveDateTime; N]
fn into_dart(self) -> DartCObject
source§impl<T, E> IntoDart for Result<T, E>where
T: IntoDart,
E: ToString,
impl<T, E> IntoDart for Result<T, E>where
T: IntoDart,
E: ToString,
fn into_dart(self) -> DartCObject
source§impl<T> IntoDart for Vec<T, Global>where
T: IntoDartExceptPrimitive,
impl<T> IntoDart for Vec<T, Global>where
T: IntoDartExceptPrimitive,
fn into_dart(self) -> DartCObject
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