Expand description
Define a foreign function interface (FFI) for this crate.
The FFI allows demes to be used by any language compatible with the C calling convention.
We recommend cbindgen to generate a C or C++ header file from this module.
We suggest corrosion
for building using cmake
.
It should be possible to use other build systems such as meson
.
However, we have not experimented with this.
We will update this section if and when we do so.
See the c_example
folder in the demes
folder of this crate’s
repository for a fully
worked out example.
§Notes
The rust API stores all strings as String
, which is very different
from the C pointer to std::ffi::c_char
.
Therefore, most functions returning * c_char
return a copy of the
data stored by rust.
It is up to the client code to free these returned data.
Functions returning pointers all document if the return value must be freed and, if so, how to do so.
Many of the function in this module do not have an unsafe
label.
These labels are correct.
When called from rust, these functions are indeed safe.
The borrow checker prevents them from being unsafe.
However, when called from languages like C
, this API is subject
to the same safety pitfalls as any API for that language.
Witout rust’s borrow checker, it is up to client code to make
sure that parent objects (Graph
s for example) are still valid
when child objects (Deme
s for example) are passed to API functions.
Structs§
- Opaque error type.
Enums§
- The size function for an epoch.
Functions§
- Get the destination deme of a
AsymmetricMigration
- Get the end time of a
AsymmetricMigration
- Get the rate of a
AsymmetricMigration
- Get the source deme of a
AsymmetricMigration
- Get the start time of a
AsymmetricMigration
- Free the memory for a C-style string that was allocated by this module.
- Get a pointer to the indexes of all ancestors of a
Deme
- Get the end time of a
Deme
. - Get the end time of a
Deme
. - Get the name of a
Deme
. - Get the number of ancestors of a
Deme
. - Get the number of epochs in a
Deme
- Get the ancestry proportions of a
Deme
. - Get the size of a
Deme
at a specific time. - Get the start size of a
Deme
. - Get the start time of a
Deme
. - Get the end size of an
Epoch
. - Get the end time of an
Epoch
. - Get the size of an
Epoch
at a specific time. - Get the
SizeFunction
of anEpoch
. - Get the start size of an
Epoch
. - Get the start time of an
Epoch
. - Allocate a
FFIError
- Clear error state.
- Free the memory for a
FFIError
- Check if a
FFIError
contains an error state. - Obtain a C string containing the error message.
- Free the memory for a
Graph
- Generate a copy of a
Graph
with time units changed to generations. - Initialize a
Graph
from a file. - Initialize a
Graph
from a YAML string. - Get a pointer to an
AsymmetricMigration
from aGraph
- Get the number of demes in a
Graph
- Get the number of
AsymmetricMigration
items in aGraph
. - Return a string representation of the
Graph
- Return a string representation of the
Graph
’s toplevel metadata in JSON format - Return a string representation of the
Graph
’s toplevel metadata in YAML format - Get the number of source demes of a
Pulse
. - Get a pointer to all ancestry proportions for a
Pulse
. - Get the source deme of a
Pulse
. - Get the time of a
Pulse
.