use reifydb_abi::{
callbacks::{
catalog::CatalogCallbacks, host::HostCallbacks, log::LogCallbacks, memory::MemoryCallbacks,
rql::RqlCallbacks, state::StateCallbacks, store::StoreCallbacks,
},
constants::FFI_ERROR_INTERNAL,
context::context::ContextFFI,
data::buffer::BufferFFI,
};
use reifydb_extension::procedure::ffi_callbacks::{logging, memory};
pub mod catalog;
pub mod state;
pub mod state_iterator;
pub mod store;
pub mod store_iterator;
pub fn create_host_callbacks() -> HostCallbacks {
HostCallbacks {
memory: MemoryCallbacks {
alloc: memory::host_alloc,
free: memory::host_free,
realloc: memory::host_realloc,
},
state: StateCallbacks {
get: state::host_state_get,
set: state::host_state_set,
remove: state::host_state_remove,
clear: state::host_state_clear,
prefix: state::host_state_prefix,
range: state::host_state_range,
iterator_next: state::host_state_iterator_next,
iterator_free: state::host_state_iterator_free,
},
log: LogCallbacks {
message: logging::host_log_message,
},
store: StoreCallbacks {
get: store::host_store_get,
contains_key: store::host_store_contains_key,
prefix: store::host_store_prefix,
range: store::host_store_range,
iterator_next: store::host_store_iterator_next,
iterator_free: store::host_store_iterator_free,
},
catalog: CatalogCallbacks {
find_namespace: catalog::host_catalog_find_namespace,
find_namespace_by_name: catalog::host_catalog_find_namespace_by_name,
find_table: catalog::host_catalog_find_table,
find_table_by_name: catalog::host_catalog_find_table_by_name,
free_namespace: catalog::host_catalog_free_namespace,
free_table: catalog::host_catalog_free_table,
},
rql: RqlCallbacks {
rql: host_rql_unsupported,
},
}
}
extern "C" fn host_rql_unsupported(
_ctx: *mut ContextFFI,
_rql_ptr: *const u8,
_rql_len: usize,
_params_ptr: *const u8,
_params_len: usize,
_result_out: *mut BufferFFI,
) -> i32 {
FFI_ERROR_INTERNAL
}