Expand description
Foreign Function Interface (FFI) for the Libket library.
This module provides a C-compatible API for the core data structures and execution mechanisms in Libket, enabling it to be consumed by other languages such as Python, C, and C++.
§Design overview
All opaque Rust types (crate::process::Process,
crate::ir::block::BasicBlock, crate::process::QPUConfig,
crate::execution::QuantumExecution) are heap-allocated behind raw pointers.
Callers are responsible for pairing every *_new call with the corresponding
*_delete call to avoid memory leaks.
Gate instructions and measurement results are exchanged as JSON strings
(const char *). The caller owns any char * that Libket writes into an
output pointer and must free it by calling ket_string_delete when
done. Static C strings (e.g., the status returned by
ket_process_status) are not heap-allocated and must not be freed.
Every exported function returns a signed 32-bit integer error code. A
return value of 0 indicates success. Non-zero values map to the
KetError variants via KetError::from_error_code; call
ket_error_message to retrieve a human-readable description.
Modules§
- block
- C API for interacting with
BasicBlockoperations. - execute
- C API bindings for quantum execution backends.
- process
- C API for interacting with
Processoperations.
Functions§
- ket_
build_ info - Returns a pointer and byte-length for a static build-information string.
- ket_
error_ message - Retrieves the human-readable error message for a given integer error code.
- ket_
string_ delete - Frees a heap-allocated C string that was previously written by Libket.