Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mapping for Primitives

The basic data types have the mappings shown below.

IDLRustDefault value
booleanboolfalse
octetu80
int8i80
uint8u80
int16i160
uint16u160
int32i320
uint32u320
int64i640
uint64u640
shorti160
longi320
floatf320_f32
doublef640_f64
long doublef640_f64
charchar'\x00'
wcharchar'\x00'
char8char'\x00'
char16char'\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.