entelechy-ffiGenerated
Layer: interface · Lines of code: 1,638 · Integration test files: 3
C ABI host: a session as a library any program loads in its own process, the Fields read in place
Description
Section titled “Description”Entelechy as a library in another process: the session the CLI and the
Player run, behind the C ABI in include/entelechy.h. A host opens a scene,
evaluates it under its own input, and reads Fields in place in the
Host’s memory; the JSON protocol is reachable one line at a time.
A session is used from one thread and one call at a time: a call made
while another is inside it is refused (EntelechySession). Returned
strings and pointers belong to the session until the next call on it;
a Field’s words until the next evaluate, request or close. No panic
crosses the boundary: each entry reports one as an error.
| Internal dependencies | entelechy-abi, entelechy-gpu, entelechy-graph, entelechy-kernel, entelechy-protocol, entelechy-session |
| External dependencies | — |
| Source | crates/interface/ffi |
Structs
Section titled “Structs”| Name | Brief |
|---|---|
EntelechyInput |
What an evaluation sees; the layout of EntelechyInput in the header. |
EntelechyPointer |
The scene’s pointer as it lies in memory; the layout of EntelechyPointer in the header. |
EntelechyField |
A Field as it lies in memory; the layout of EntelechyField in the header. |
EntelechySession |
A session as a caller holds it, and whether a call is inside it. A call made while another is inside (a page reaching in while Entelechy waits for its device) is refused as a NULL session is, so no two calls touch what is held at once. |
EntelechyFiles |
An in-memory file store a session opened on it reads instead of a disk. Files put after opening are read on the session’s next evaluate. |
Functions
Section titled “Functions”| Function | Brief |
|---|---|
fn entelechy_version() -> *const c_char |
The library’s version. |
unsafe fn entelechy_open(scene: *const c_char, backend: *const c_char, library: *const c_char) -> *mut EntelechySession |
Opens a scene on a backend; NULL with entelechy_open_error set on failure. |
fn entelechy_files() -> *mut EntelechyFiles |
A new, empty set of files. In a page, a file put elsewhere (entelechy_files_put_elsewhere) is read through entelechy.fetch. |
unsafe fn entelechy_files_put_elsewhere(files: *mut EntelechyFiles, path: *const c_char, len: usize) -> c_int |
Puts a file of len bytes at path whose bytes the caller keeps: in a page, read through entelechy.fetch whenever the file is read, so they are not held twice. Elsewhere such a file cannot be read. |
unsafe fn entelechy_files_put(files: *mut EntelechyFiles, path: *const c_char, data: *const u8, len: usize) -> c_int |
Puts a file’s bytes at path, replacing what was there. |
unsafe fn entelechy_files_free(files: *mut EntelechyFiles) |
Releases the caller’s hold on a set of files; a session opened on them keeps its own. |
unsafe fn entelechy_open_files(files: *mut EntelechyFiles, scene: *const c_char, backend: *const c_char) -> *mut EntelechySession |
Opens a scene whose documents are files, as entelechy_open without the disk. |
fn entelechy_alloc(size: usize) -> *mut u8 |
Allocates size bytes in Entelechy’s memory for a caller with no shared allocator (a page, where Entelechy is WebAssembly); NULL on failure. |
unsafe fn entelechy_free(pointer: *mut u8, size: usize) |
Frees what entelechy_alloc gave, with the size it was asked for. |
fn entelechy_open_error() -> *const c_char |
Why the last entelechy_open on this thread failed. |
unsafe fn entelechy_close(session: *mut EntelechySession) |
Ends a session, the frame in flight confirmed first, so what it writes to files is written. |
unsafe fn entelechy_error(session: *const EntelechySession) -> *const c_char |
Why the last call on the session failed, or “”. |
unsafe fn entelechy_evaluate(session: *mut EntelechySession, input: *const EntelechyInput) -> c_int |
Evaluates the scene once under input. |
unsafe fn entelechy_report(session: *const EntelechySession) -> *const c_char |
The last evaluation’s report as JSON. |
unsafe fn entelechy_output(session: *mut EntelechySession, name: *const c_char, field: *mut EntelechyField) -> c_int |
A graph output’s Field. |
unsafe fn entelechy_present(session: *mut EntelechySession, canvas: *const c_char, output: *const c_char) -> c_int |
Draws a graph output (output NULL for the first) on the page’s canvas with element id canvas, straight from the GPU. Returns 0 when drawn, 1 when there is no display or the output is no picture the device holds, -1 on error. |
unsafe fn entelechy_node(session: *mut EntelechySession, node: *const c_char, port: *const c_char, field: *mut EntelechyField) -> c_int |
A node’s port. |
unsafe fn entelechy_allow(session: *mut EntelechySession, allowance: *const c_char) -> c_int |
Allows the scene a directory beyond its own, as --allow does: file.read=<dir> or file.write=<dir>. Protocol reads and writes are held to the scene’s directories and these. |
unsafe fn entelechy_request(session: *mut EntelechySession, line: *const c_char) -> *const c_char |
One protocol request line; the response line. |
Constants
Section titled “Constants”| Name | Type | Value | Brief |
|---|---|---|---|
ABI_VERSION |
u32 |
2 |
The version of the header’s contract, ENTELECHY_ABI_VERSION. |
Re-exports
Section titled “Re-exports”play
EntelechyInput
Section titled “EntelechyInput”crates/interface/ffi/src/lib.rs#L27
What an evaluation sees; the layout of EntelechyInput in the header.
Properties
| Name | Type | Description |
|---|---|---|
time |
f64 |
|
rate |
f32 |
|
pointer |
[f32; 2] |
|
wheel |
[f32; 2] |
|
window |
[f32; 2] |
|
scale |
f32 |
|
buttons |
u32 |
|
keys |
[u32; 8] |
Implemented traits: Clone, Copy, Debug, Default
EntelechyPointer
Section titled “EntelechyPointer”crates/interface/ffi/src/lib.rs#L57
The scene’s pointer as it lies in memory; the layout of
EntelechyPointer in the header.
Properties
| Name | Type | Description |
|---|---|---|
rgba |
*const u8 |
|
width |
u32 |
|
height |
u32 |
|
hotspot_x |
u32 |
|
hotspot_y |
u32 |
Implemented traits: Clone, Copy, Debug
EntelechyField
Section titled “EntelechyField”crates/interface/ffi/src/lib.rs#L68
A Field as it lies in memory; the layout of EntelechyField in the header.
Properties
| Name | Type | Description |
|---|---|---|
words |
*const u32 |
|
width |
u32 |
|
height |
u32 |
|
depth |
u32 |
|
count |
u32 |
|
stride |
u32 |
|
shape |
u32 |
|
pixels |
u32 |
|
schema |
*const c_char |
Implemented traits: Clone, Copy, Debug
EntelechySession
Section titled “EntelechySession”crates/interface/ffi/src/lib.rs#L84
A session as a caller holds it, and whether a call is inside it. A call made while another is inside (a page reaching in while Entelechy waits for its device) is refused as a NULL session is, so no two calls touch what is held at once.
EntelechyFiles
Section titled “EntelechyFiles”crates/interface/ffi/src/lib.rs#L564
An in-memory file store a session opened on it reads instead of a disk. Files put after opening are read on the session’s next evaluate.

