#![allow(non_camel_case_types)]
use std::os::raw::{c_char, c_void};
pub const FOLDIT_PLUGIN_ABI_VERSION: u32 = 7;
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FolditPluginAssemblyPayloadKind {
Full = 0,
Delta = 1,
}
#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FolditPluginStatus {
Ok = 0,
Err = 1,
Unsupported = 2,
}
#[repr(C)]
#[derive(Debug)]
pub struct FolditPluginBuffer {
pub data: *mut u8,
pub len: usize,
pub capacity: usize,
}
impl FolditPluginBuffer {
#[must_use]
pub const fn empty() -> Self {
Self {
data: std::ptr::null_mut(),
len: 0,
capacity: 0,
}
}
}
#[repr(C)]
#[derive(Debug)]
pub struct FolditPluginError {
pub code: FolditPluginBuffer,
pub message: FolditPluginBuffer,
}
impl FolditPluginError {
#[must_use]
pub const fn empty() -> Self {
Self {
code: FolditPluginBuffer::empty(),
message: FolditPluginBuffer::empty(),
}
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct FolditPluginVec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct FolditPluginResidueRef {
pub entity_id: u64,
pub residue_index: u32,
pub padding: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct FolditPluginDispatchContext {
pub has_focused_entity: u8,
pub padding: [u8; 7],
pub focused_entity_id: u64,
pub selection: *const FolditPluginResidueRef,
pub selection_len: usize,
pub designable: *const FolditPluginResidueRef,
pub designable_len: usize,
}
#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FolditPluginParamTag {
Unspecified = 0,
Int = 1,
Float = 2,
Bool = 3,
String = 4,
Vec3 = 5,
}
#[repr(C)]
#[derive(Debug)]
pub struct FolditPluginParamValue {
pub tag: FolditPluginParamTag,
pub padding: u32,
pub int_value: i32,
pub float_value: f32,
pub bool_value: u8,
pub padding2: [u8; 7],
pub string_data: *const u8,
pub string_len: usize,
pub vec3_value: FolditPluginVec3,
}
#[repr(C)]
#[derive(Debug)]
pub struct FolditPluginParamEntry {
pub key_data: *const u8,
pub key_len: usize,
pub value: FolditPluginParamValue,
}
#[repr(C)]
#[derive(Debug)]
pub struct FolditPluginAsset {
pub name_data: *const u8,
pub name_len: usize,
pub data: *const u8,
pub data_len: usize,
}
pub type FolditPluginHandle = *mut c_void;
#[repr(C)]
pub struct FolditPluginVtable {
pub abi_version: u32,
pub padding: u32,
pub create:
unsafe extern "C" fn(config_json: *const c_char, config_len: usize) -> FolditPluginHandle,
pub destroy: unsafe extern "C" fn(handle: FolditPluginHandle),
pub register: unsafe extern "C" fn(
handle: FolditPluginHandle,
out_buf: *mut FolditPluginBuffer,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub init: unsafe extern "C" fn(
handle: FolditPluginHandle,
assembly: *const u8,
assembly_len: usize,
assets: *const FolditPluginAsset,
assets_len: usize,
params: *const FolditPluginParamEntry,
params_len: usize,
out_session: *mut u64,
out_initial_buf: *mut FolditPluginBuffer,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub update_assembly: unsafe extern "C" fn(
handle: FolditPluginHandle,
session: u64,
payload_kind: FolditPluginAssemblyPayloadKind,
bytes: *const u8,
bytes_len: usize,
from_gen: u64,
to_gen: u64,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub drop_session: unsafe extern "C" fn(
handle: FolditPluginHandle,
session: u64,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub invoke: unsafe extern "C" fn(
handle: FolditPluginHandle,
session: u64,
op_id: *const u8,
op_id_len: usize,
ctx: *const FolditPluginDispatchContext,
params: *const FolditPluginParamEntry,
params_len: usize,
out_assembly: *mut FolditPluginBuffer,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub start_stream: unsafe extern "C" fn(
handle: FolditPluginHandle,
session: u64,
op_id: *const u8,
op_id_len: usize,
ctx: *const FolditPluginDispatchContext,
params: *const FolditPluginParamEntry,
params_len: usize,
request_id: u64,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub poll_stream: unsafe extern "C" fn(
handle: FolditPluginHandle,
request_id: u64,
out_buf: *mut FolditPluginBuffer,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub update_stream: unsafe extern "C" fn(
handle: FolditPluginHandle,
request_id: u64,
params: *const FolditPluginParamEntry,
params_len: usize,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub cancel_stream: unsafe extern "C" fn(
handle: FolditPluginHandle,
request_id: u64,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub query: unsafe extern "C" fn(
handle: FolditPluginHandle,
session: u64,
query_id: *const u8,
query_id_len: usize,
ctx: *const FolditPluginDispatchContext,
params: *const FolditPluginParamEntry,
params_len: usize,
assembly: *const u8,
assembly_len: usize,
out_data: *mut FolditPluginBuffer,
out_err: *mut FolditPluginError,
) -> FolditPluginStatus,
pub free_buffer: unsafe extern "C" fn(buf: *mut FolditPluginBuffer),
pub free_error: unsafe extern "C" fn(err: *mut FolditPluginError),
}
pub const VTABLE_SYMBOL: &[u8] = b"foldit_plugin_vtable\0";
pub type FolditPluginVtableFn = unsafe extern "C" fn() -> *const FolditPluginVtable;