Module compiler

ffi

dload loads a shared library, declare describes a C function’s signature with the type tags from ffi::types, and invoke calls it. An extern "lib" { … } block does the same at compile time; see the FFI tutorial.

Loading is gated. A program can dload a library only when it is allowed with --allow-dload NAME and either pinned by hash (--dload-pin NAME=SHA256) or trusted (--dload-trusted NAME); --ffi-search-path DIR says where to look. spool sets these from the project’s coil.toml and lockfile. The C library (dload("c")) is always denied. Pin a Coil value with gc::root before giving C a pointer it keeps.

Built into the compiler.

Import what you use (use path::* is not allowed):

use ffi::{ErrorKind, Error};

Modules#

ModuleDescription
ffi::typesType tags that describe C argument and return types to ffi::declare.

Types#

NameDescription
ErrorKindThe category of an FFI failure, read from Error.kind.
ErrorThe error of dload, declare, invoke and read_ints.

Functions#

NameDescription
dloadLoads a native shared library and returns a handle to it.
declareLooks up the C function name in a loaded library and records its signature.
invokeCalls a function registered with declare, passing the tuple args.
read_intsCopies count 64-bit integers (int64_t) from native memory at ptr.
↑ ↓ navigate ↵ open