#[repr(C)]pub struct CLiveExecution {
pub compute_gate: fn(json: *const c_char) -> i32,
pub compute_native_gates: fn(json: *const c_char) -> i32,
pub measure: fn(qubits: *const usize, len: usize, result: &mut u64) -> i32,
pub dump: fn(qubits: *const usize, len: usize, result_json: &mut *const c_char) -> i32,
pub sample: fn(qubits: *const usize, len: usize, shots: usize, result_json: &mut *const c_char) -> i32,
pub exp_value: fn(hamiltonian_json: *const c_char, result: &mut f64) -> i32,
}Expand description
FFI-compatible function-pointer table for a live (gate-at-a-time) execution backend.
In live mode each gate is dispatched to the hardware or simulator
immediately as it is applied to the process, and measurement results are
available without an explicit ket_process_execute call.
Construct a CLiveExecution value on the C side, fill in all function
pointers, then call ket_quantum_execution_live to create the
corresponding QuantumExecution variant.
All callbacks must return 0 on success or a non-zero libket error code on
failure.
Fields§
§compute_gate: fn(json: *const c_char) -> i32Dispatch a single quantum gate to the backend.
json is a null-terminated JSON string encoding the gate instruction
(type, parameters, target qubit, etc.). Returns 0 on success.
compute_native_gates: fn(json: *const c_char) -> i32Dispatch a sequence of pre-translated native gate instructions to the backend.
json is a null-terminated JSON string encoding the array of native
gate instructions (each a [name, angles, qubits] triple). Returns 0
on success.
measure: fn(qubits: *const usize, len: usize, result: &mut u64) -> i32Perform a single-shot measurement of len qubits.
qubits points to an array of len qubit indices. On success the
measurement result is written to *result as a bitmask where bit i
corresponds to qubits[i]. Returns 0 on success.
dump: fn(qubits: *const usize, len: usize, result_json: &mut *const c_char) -> i32Retrieve the full quantum state (probability amplitudes) of len qubits.
qubits points to an array of len qubit indices. On success
*result_json is set to a heap-allocated null-terminated JSON string
encoding the state; Rust will parse it and then it is the C side’s
responsibility to manage the lifetime. Returns 0 on success.
sample: fn(qubits: *const usize, len: usize, shots: usize, result_json: &mut *const c_char) -> i32Perform a repeated measurement sample of len qubits over shots shots.
qubits points to an array of len qubit indices. On success
*result_json is set to a heap-allocated null-terminated JSON string
with the sample counts. Returns 0 on success.
exp_value: fn(hamiltonian_json: *const c_char, result: &mut f64) -> i32Compute the expectation value of a Hamiltonian on the current quantum state.
hamiltonian_json is a null-terminated JSON string encoding the
Hamiltonian. On success *result is set to the computed expectation
value. Returns 0 on success.
Trait Implementations§
Source§impl Clone for CLiveExecution
impl Clone for CLiveExecution
Source§fn clone(&self) -> CLiveExecution
fn clone(&self) -> CLiveExecution
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CLiveExecution
impl Debug for CLiveExecution
Source§impl LiveExecution for CLiveExecution
impl LiveExecution for CLiveExecution
Source§fn compute_gate(&mut self, gate: &GateInstruction) -> Result<(), KetError>
fn compute_gate(&mut self, gate: &GateInstruction) -> Result<(), KetError>
Source§fn compute_native_gates(&mut self, gates: &[NativeGate]) -> Result<(), KetError>
fn compute_native_gates(&mut self, gates: &[NativeGate]) -> Result<(), KetError>
Source§fn measure(&mut self, qubits: &[usize]) -> Result<u64, KetError>
fn measure(&mut self, qubits: &[usize]) -> Result<u64, KetError>
qubits, returning the result as
a packed integer (bit i corresponds to qubits[i]). Read moreAuto Trait Implementations§
impl Freeze for CLiveExecution
impl RefUnwindSafe for CLiveExecution
impl Send for CLiveExecution
impl Sync for CLiveExecution
impl Unpin for CLiveExecution
impl UnsafeUnpin for CLiveExecution
impl UnwindSafe for CLiveExecution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more