[−][src]Module ffishim::types
Definition of accepted types and their behavior.
Here is a list of the available complex types and their FFI equivalents.
If a type deriving the ffi shim contains references to types that are not listed below, they
will by default be considered Foreign
types. It will be assumed that Foreign
types
derive the ffi shim themselves, and will be manipulated as such. See the Foreign
behavior for
more details.
Complex types | FFI equivalent |
---|---|
String | *mut u8 |
Option<T> | *mut T |
Vec<T> | ffishim::library::FFIVec<T> |
Result<T, E> | ffishim::library::FFIResult<T> |
chrono::Duration | libc::c_long |
And below a list of all the scalar types handled (see the Scalars
behavior for more details.)
Scalar types | FFI equivalent |
---|---|
bool | libc::c_char |
char | libc::c_uint |
f32 | libc::c_float |
f64 | libc::c_double |
u8 | libc::c_char |
u16 | libc::c_ushort |
u32 | libc::c_uint |
u64 | libc::c_ulong |
usize | libc::size_t |
i8 | libc::c_schar |
i16 | libc::c_short |
i32 | libc::c_int |
i64 | libc::c_long |
isize | libc::ssize_t |
If you want to add a type behavior, just:
- Create a new struct in a sub-module
- Implement the
Behavior
trait - Add the struct in the private
BEHAVIORS
vector
Structs
Bool | The std lib's |
Char | The std lib's |
Duration | chrono::Duration type behavior |
Foreign | Any unknown type's behavior, assumed to implement an ffi shim. |
Option | The std lib's |
Reference | Behavior for references to types (& and &mut). |
Result | The std lib's |
Scalars | Builtin scalar behaviors: |
String | The std lib's |
Vector | The std lib's |
Traits
Behavior | The behavior of a |
Functions
switch | Switch over a given |