Mapping for Primitives
The basic data types have the mappings shown below.
| IDL | Rust | Default value |
|---|---|---|
boolean | bool | false |
octet | u8 | 0 |
int8 | i8 | 0 |
uint8 | u8 | 0 |
int16 | i16 | 0 |
uint16 | u16 | 0 |
int32 | i32 | 0 |
uint32 | u32 | 0 |
int64 | i64 | 0 |
uint64 | u64 | 0 |
short | i16 | 0 |
long | i32 | 0 |
float | f32 | 0_f32 |
double | f64 | 0_f64 |
long double | f64 | 0_f64 |
char | char | '\x00' |
wchar | char | '\x00' |
char8 | char | '\x00' |
char16 | char | '\x00' |
All of the above types are primitive, built-in types. Rust chars are
guaranteed to be valid UTF-8 characters.
Limitations
Long Double
The IDL long double type is mapped to f64 in Rust, which is the same as
double. Rust does not have not yet have native support for 80-bit or 128-bit
floating point types in the standard library. This means that long double
values may lose precision when used in Rust code. If higher precision is
required, an implementation may provide a custom implementation of an
f128-equivalent type.
There is an open RFC for
adding support for an f128 type, but it is not yet stabilized.