Expand description
C API bindings for quantum execution backends.
This module defines the FFI-compatible structs (CLiveExecution,
CBatchExecution, CNativeGateSet) that allow external C/C++ quantum
simulators or hardware drivers to plug into the Libket execution pipeline.
§JSON serialization contract
All data exchanged between Rust and the C callbacks is serialized as JSON:
- Rust → C: gate instructions, Hamiltonians, and gate matrices are
serialized with
serde_jsoninto null-terminated C strings before being passed to the corresponding callback. - C → Rust: JSON strings returned by C callbacks (e.g., sample counts,
state dumps, native gate sequences) are parsed back with
serde_jsonon the Rust side. If parsing fails,KetError::SerdeErroris returned.
Heap-allocated strings returned by C callbacks are not freed by Rust;
the C backend is responsible for their lifetime (typically they are freed
via super::ket_string_delete by the caller of the top-level C API).
Structs§
- CBatch
Execution - FFI-compatible function-pointer table for a batch execution backend.
- CLive
Execution - FFI-compatible function-pointer table for a live (gate-at-a-time) execution backend.
- CNative
Gate Set - FFI-compatible function-pointer table for translating abstract gates into backend-native instructions.
Functions§
- ket_
quantum_ execution_ batch - Creates a batch-mode
QuantumExecutionbacked by the provided callback tables. - ket_
quantum_ execution_ live - Creates a live-mode
QuantumExecutionbacked by the provided callback table.