allo_isolate/
into_dart_extra.rs

1//! The conversions in this file is not lossless. On the contrary, it is lossy
2//! and the type that Dart receives will not be the same as the type you send in
3//! Rust. For example, numeric types can become String.
4
5use crate::{ffi::*, IntoDart};
6
7impl IntoDart for i8 {
8    fn into_dart(self) -> DartCObject {
9        (self as i32).into_dart()
10    }
11}
12
13impl IntoDart for i16 {
14    fn into_dart(self) -> DartCObject {
15        (self as i32).into_dart()
16    }
17}
18
19impl IntoDart for u8 {
20    fn into_dart(self) -> DartCObject {
21        (self as i32).into_dart()
22    }
23}
24
25impl IntoDart for u16 {
26    fn into_dart(self) -> DartCObject {
27        (self as i32).into_dart()
28    }
29}
30
31impl IntoDart for u32 {
32    fn into_dart(self) -> DartCObject {
33        (self as i64).into_dart()
34    }
35}
36
37impl IntoDart for u64 {
38    fn into_dart(self) -> DartCObject {
39        (self as i64).into_dart()
40    }
41}
42
43impl IntoDart for i128 {
44    fn into_dart(self) -> DartCObject {
45        self.to_string().into_dart()
46    }
47}
48
49impl IntoDart for u128 {
50    fn into_dart(self) -> DartCObject {
51        self.to_string().into_dart()
52    }
53}
54
55#[cfg(target_pointer_width = "64")]
56impl IntoDart for usize {
57    fn into_dart(self) -> DartCObject {
58        (self as u64 as i64).into_dart()
59    }
60}
61
62#[cfg(target_pointer_width = "32")]
63impl IntoDart for usize {
64    fn into_dart(self) -> DartCObject {
65        (self as u32 as i32).into_dart()
66    }
67}
68
69#[cfg(target_pointer_width = "64")]
70impl IntoDart for isize {
71    fn into_dart(self) -> DartCObject {
72        (self as i64).into_dart()
73    }
74}
75
76#[cfg(target_pointer_width = "32")]
77impl IntoDart for isize {
78    fn into_dart(self) -> DartCObject {
79        (self as i32).into_dart()
80    }
81}
82
83impl IntoDart for char {
84    fn into_dart(self) -> DartCObject {
85        (self as u32).into_dart()
86    }
87}