Types
Diplomat only supports a small set of types that can be passed over FFI. These are:
- Builtins:
- All integers, as well as
bool
andchar
&[T]
whereT
is an integer,bool
, orchar
&str
(string slices)DiplomatWriteable
for returning stringsResult<T, E>
in return valuesOption<T>
of opaque types()
as aResult
Ok
/Error
type, or as a return value
- All integers, as well as
- Custom types
- Custom opaque types (passed as references or via
Box<T>
) - Custom structs and C-like enums
- Custom opaque types (passed as references or via
More types can be supported in the future (We have issues for iterators and callbacks)
The main distinction to keep track of is between "opaque types" and "structs": opaque types are for when you want to wrap a Rust object that has its own semantics, whereas "structs" are for when you want to transparently pass around multiple values at once (usually when you want to make an options struct as an argument, or return multiple values at once).