bloqade_lanes_bytecode/ffi/
handles.rs

1use std::ffi::CString;
2
3use bloqade_lanes_bytecode_core::arch::ArchSpec;
4use bloqade_lanes_bytecode_core::bytecode::program::Program;
5use bloqade_lanes_bytecode_core::bytecode::validate::ValidationError;
6
7/// Opaque handle wrapping a `Program`.
8pub struct BLQDProgram {
9    pub(crate) inner: Program,
10}
11
12/// Opaque handle wrapping an `ArchSpec`.
13pub struct BLQDArchSpec {
14    pub(crate) inner: ArchSpec,
15}
16
17/// Opaque handle wrapping a list of validation errors with cached CString messages.
18pub struct BLQDValidationErrors {
19    pub(crate) errors: Vec<ValidationError>,
20    pub(crate) messages: Vec<CString>,
21}
22
23impl BLQDValidationErrors {
24    pub(crate) fn from_errors(errors: Vec<ValidationError>) -> Self {
25        let messages = errors
26            .iter()
27            .map(|e| CString::new(e.to_string()).unwrap_or_default())
28            .collect();
29        Self { errors, messages }
30    }
31}