Trait flutter_rust_bridge::ffi::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§
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>
impl IntoDart for Vec<NaiveDateTime>
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 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<A, B, C, D> IntoDart for (A, B, C, D)
impl<A, B, C, D> IntoDart for (A, B, C, D)
fn into_dart(self) -> DartCObject
source§impl<A, B, C, D, E> IntoDart for (A, B, C, D, E)
impl<A, B, C, D, E> IntoDart for (A, B, C, D, E)
fn into_dart(self) -> DartCObject
source§impl<A, B, C, D, E, F> IntoDart for (A, B, C, D, E, F)
impl<A, B, C, D, E, F> IntoDart for (A, B, C, D, E, F)
fn into_dart(self) -> DartCObject
source§impl<A, B, C, D, E, F, G> IntoDart for (A, B, C, D, E, F, G)
impl<A, B, C, D, E, F, G> IntoDart for (A, B, C, D, E, F, G)
fn into_dart(self) -> DartCObject
source§impl<A, B, C, D, E, F, G, H> IntoDart for (A, B, C, D, E, F, G, H)
impl<A, B, C, D, E, F, G, H> IntoDart for (A, B, C, D, E, F, G, H)
fn into_dart(self) -> DartCObject
source§impl<A, B, C, D, E, F, G, H, I> IntoDart for (A, B, C, D, E, F, G, H, I)
impl<A, B, C, D, E, F, G, H, I> IntoDart for (A, B, C, D, E, F, G, H, I)
fn into_dart(self) -> DartCObject
source§impl<A, B, C, D, E, F, G, H, I, J> IntoDart for (A, B, C, D, E, F, G, H, I, J)
impl<A, B, C, D, E, F, G, H, I, J> IntoDart for (A, B, C, D, E, F, G, H, I, J)
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.