use std::ffi::c_void;
use super::types::{
AsyncExecutorFn, FfiChangeOp, FfiComponentStatus, FfiCreateResult, FfiDispatchMode,
FfiGetResult, FfiOwnedStr, FfiResult, FfiStr, FfiStringArray,
};
#[repr(C)]
pub struct FfiSourceEvent {
pub opaque: *mut c_void,
pub source_id: FfiStr,
pub timestamp_us: i64,
pub op: FfiChangeOp,
pub label: FfiStr,
pub entity_id: FfiStr,
pub drop_fn: extern "C" fn(*mut c_void),
}
#[repr(C)]
pub struct FfiBootstrapEvent {
pub opaque: *mut c_void,
pub source_id: FfiStr,
pub timestamp_us: i64,
pub sequence: u64,
pub label: FfiStr,
pub entity_id: FfiStr,
pub drop_fn: extern "C" fn(*mut c_void),
}
pub type FfiChangePushCallbackFn =
extern "C" fn(ctx: *mut c_void, event: *mut FfiSourceEvent) -> bool;
#[repr(C)]
pub struct FfiChangeReceiver {
pub state: *mut c_void,
pub executor: AsyncExecutorFn,
pub start_push_fn: extern "C" fn(
state: *mut c_void,
callback: FfiChangePushCallbackFn,
callback_ctx: *mut c_void,
),
pub drop_fn: extern "C" fn(state: *mut c_void),
}
unsafe impl Send for FfiChangeReceiver {}
unsafe impl Sync for FfiChangeReceiver {}
pub type FfiBootstrapPushCallbackFn =
extern "C" fn(ctx: *mut c_void, event: *mut FfiBootstrapEvent) -> bool;
#[repr(C)]
pub struct FfiBootstrapReceiver {
pub state: *mut c_void,
pub start_push_fn: extern "C" fn(
state: *mut c_void,
callback: FfiBootstrapPushCallbackFn,
callback_ctx: *mut c_void,
),
pub drop_fn: extern "C" fn(state: *mut c_void),
}
unsafe impl Send for FfiBootstrapReceiver {}
unsafe impl Sync for FfiBootstrapReceiver {}
#[repr(C)]
pub struct FfiSubscriptionResponse {
pub query_id: FfiOwnedStr,
pub source_id: FfiOwnedStr,
pub receiver: *mut FfiChangeReceiver,
pub bootstrap_receiver: *mut FfiBootstrapReceiver,
}
pub type FfiResultPushCallbackFn =
extern "C" fn(ctx: *mut c_void, result: *mut c_void) -> *mut c_void;
#[repr(C)]
pub struct FfiBootstrapSender {
pub state: *mut c_void,
pub send_fn: extern "C" fn(state: *mut c_void, event: *mut FfiBootstrapEvent) -> i32,
pub drop_fn: extern "C" fn(state: *mut c_void),
}
unsafe impl Send for FfiBootstrapSender {}
unsafe impl Sync for FfiBootstrapSender {}
#[repr(C)]
pub struct FfiRuntimeContext {
pub instance_id: FfiStr,
pub component_id: FfiStr,
pub state_store: *const StateStoreVtable,
pub log_callback: Option<super::callbacks::LogCallbackFn>,
pub log_ctx: *mut c_void,
pub lifecycle_callback: Option<super::callbacks::LifecycleCallbackFn>,
pub lifecycle_ctx: *mut c_void,
pub identity_provider: *const super::identity::IdentityProviderVtable,
}
unsafe impl Send for FfiRuntimeContext {}
unsafe impl Sync for FfiRuntimeContext {}
drasi_ffi_primitives::ffi_vtable! {
pub struct SourceVtable {
fn id_fn(state: *const) -> FfiStr,
fn type_name_fn(state: *const) -> FfiStr,
fn auto_start_fn(state: *const) -> bool,
fn dispatch_mode_fn(state: *const) -> FfiDispatchMode,
fn properties_fn(state: *const) -> FfiOwnedStr,
fn start_fn(state: *mut) -> FfiResult,
fn stop_fn(state: *mut) -> FfiResult,
fn status_fn(state: *const) -> FfiComponentStatus,
fn deprovision_fn(state: *mut) -> FfiResult,
fn initialize_fn(state: *mut, ctx: *const FfiRuntimeContext),
fn subscribe_fn(state: *mut, source_id: FfiStr, enable_bootstrap: bool, query_id: FfiStr, nodes_json: FfiStr, relations_json: FfiStr) -> *mut FfiSubscriptionResponse,
fn set_bootstrap_provider_fn(state: *mut, provider: *mut BootstrapProviderVtable),
}
}
drasi_ffi_primitives::ffi_vtable! {
pub struct ReactionVtable {
fn id_fn(state: *const) -> FfiStr,
fn type_name_fn(state: *const) -> FfiStr,
fn auto_start_fn(state: *const) -> bool,
fn query_ids_fn(state: *const) -> FfiStringArray,
fn properties_fn(state: *const) -> FfiOwnedStr,
fn start_fn(state: *mut) -> FfiResult,
fn stop_fn(state: *mut) -> FfiResult,
fn status_fn(state: *const) -> FfiComponentStatus,
fn deprovision_fn(state: *mut) -> FfiResult,
fn initialize_fn(state: *mut, ctx: *const FfiRuntimeContext),
fn start_result_push_fn(state: *mut, callback: FfiResultPushCallbackFn, callback_ctx: *mut c_void),
}
}
drasi_ffi_primitives::ffi_vtable! {
pub struct BootstrapProviderVtable {
fn bootstrap_fn(state: *mut, query_id: FfiStr, node_labels: *const FfiStr, node_labels_count: usize, relation_labels: *const FfiStr, relation_labels_count: usize, request_id: FfiStr, server_id: FfiStr, source_id: FfiStr, sender: *mut FfiBootstrapSender) -> i64,
}
}
drasi_ffi_primitives::ffi_vtable! {
pub struct SourcePluginVtable {
fn kind_fn(state: *const) -> FfiStr,
fn config_version_fn(state: *const) -> FfiStr,
fn config_schema_json_fn(state: *const) -> FfiOwnedStr,
fn config_schema_name_fn(state: *const) -> FfiStr,
fn create_source_fn(state: *mut, id: FfiStr, config_json: FfiStr, auto_start: bool) -> FfiCreateResult,
}
}
drasi_ffi_primitives::ffi_vtable! {
pub struct ReactionPluginVtable {
fn kind_fn(state: *const) -> FfiStr,
fn config_version_fn(state: *const) -> FfiStr,
fn config_schema_json_fn(state: *const) -> FfiOwnedStr,
fn config_schema_name_fn(state: *const) -> FfiStr,
fn create_reaction_fn(state: *mut, id: FfiStr, query_ids_json: FfiStr, config_json: FfiStr, auto_start: bool) -> FfiCreateResult,
}
}
drasi_ffi_primitives::ffi_vtable! {
pub struct BootstrapPluginVtable {
fn kind_fn(state: *const) -> FfiStr,
fn config_version_fn(state: *const) -> FfiStr,
fn config_schema_json_fn(state: *const) -> FfiOwnedStr,
fn config_schema_name_fn(state: *const) -> FfiStr,
fn create_bootstrap_provider_fn(state: *mut, config_json: FfiStr, source_config_json: FfiStr) -> FfiCreateResult,
}
}
#[repr(C)]
pub struct StateStoreVtable {
pub state: *mut c_void,
pub get_fn: extern "C" fn(state: *mut c_void, store_id: FfiStr, key: FfiStr) -> FfiGetResult,
pub set_fn: extern "C" fn(
state: *mut c_void,
store_id: FfiStr,
key: FfiStr,
value: *const u8,
value_len: usize,
) -> FfiResult,
pub delete_fn: extern "C" fn(state: *mut c_void, store_id: FfiStr, key: FfiStr) -> FfiResult,
pub contains_key_fn:
extern "C" fn(state: *mut c_void, store_id: FfiStr, key: FfiStr) -> FfiResult,
pub get_many_fn: extern "C" fn(
state: *mut c_void,
store_id: FfiStr,
keys: *const FfiStr,
keys_count: usize,
out_values: *mut FfiGetResult,
) -> FfiResult,
pub set_many_fn: extern "C" fn(
state: *mut c_void,
store_id: FfiStr,
keys: *const FfiStr,
values: *const *const u8,
value_lens: *const usize,
count: usize,
) -> FfiResult,
pub delete_many_fn: extern "C" fn(
state: *mut c_void,
store_id: FfiStr,
keys: *const FfiStr,
keys_count: usize,
) -> i64,
pub clear_store_fn: extern "C" fn(state: *mut c_void, store_id: FfiStr) -> i64,
pub list_keys_fn: extern "C" fn(state: *mut c_void, store_id: FfiStr) -> FfiStringArray,
pub store_exists_fn: extern "C" fn(state: *mut c_void, store_id: FfiStr) -> FfiResult,
pub key_count_fn: extern "C" fn(state: *mut c_void, store_id: FfiStr) -> i64,
pub sync_fn: extern "C" fn(state: *mut c_void) -> FfiResult,
pub drop_fn: extern "C" fn(state: *mut c_void),
}
unsafe impl Send for StateStoreVtable {}
unsafe impl Sync for StateStoreVtable {}
#[repr(C)]
pub struct FfiPluginRegistration {
pub source_plugins: *mut SourcePluginVtable,
pub source_plugin_count: usize,
pub reaction_plugins: *mut ReactionPluginVtable,
pub reaction_plugin_count: usize,
pub bootstrap_plugins: *mut BootstrapPluginVtable,
pub bootstrap_plugin_count: usize,
pub set_log_callback:
extern "C" fn(ctx: *mut ::std::ffi::c_void, callback: super::callbacks::LogCallbackFn),
pub set_lifecycle_callback: extern "C" fn(
ctx: *mut ::std::ffi::c_void,
callback: super::callbacks::LifecycleCallbackFn,
),
}