[][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 typesFFI equivalent
String*mut u8
Option<T>*mut T
Vec<T>ffishim::library::FFIVec<T>
Result<T, E>ffishim::library::FFIResult<T>
chrono::Durationlibc::c_long

And below a list of all the scalar types handled (see the Scalars behavior for more details.)

Scalar typesFFI equivalent
boollibc::c_char
charlibc::c_uint
f32libc::c_float
f64libc::c_double
u8libc::c_char
u16libc::c_ushort
u32libc::c_uint
u64libc::c_ulong
usizelibc::size_t
i8libc::c_schar
i16libc::c_short
i32libc::c_int
i64libc::c_long
isizelibc::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 bool type behavior.

Char

The std lib's char type behavior.

Duration

chrono::Duration type behavior

Foreign

Any unknown type's behavior, assumed to implement an ffi shim.

Option

The std lib's Option type behavior.

Reference

Behavior for references to types (& and &mut).

Result

The std lib's Result type behavior.

Scalars

Builtin scalar behaviors: f32, u32, ...

String

The std lib's String type behavior.

Vector

The std lib's Vec type behavior, backed by ffishim library's FFIVec.

Traits

Behavior

The behavior of a Type as needed to generate the ffi shim.

Functions

switch

Switch over a given Type and return the associated Behavior.