#[repr(C)]pub struct DataSourceVTable {
pub init: Option<unsafe extern "C" fn(*const u8, usize) -> *mut c_void>,
pub get_query_schema: Option<unsafe extern "C" fn(*mut c_void) -> *const QuerySchema>,
pub get_output_schema: Option<unsafe extern "C" fn(*mut c_void) -> *const OutputSchema>,
pub get_source_schema: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, *mut *mut u8, *mut usize) -> i32>,
pub validate_query: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, *mut *mut i8) -> i32>,
pub load: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, *mut *mut u8, *mut usize) -> i32>,
pub load_binary: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, u8, Option<unsafe extern "C" fn(u8, u64, u64, u64, *mut c_void) -> i32>, *mut c_void, *mut *mut u8, *mut usize) -> i32>,
pub subscribe: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, unsafe extern "C" fn(*const u8, usize, *mut c_void), *mut c_void) -> u64>,
pub unsubscribe: Option<unsafe extern "C" fn(*mut c_void, u64) -> i32>,
pub free_buffer: Option<unsafe extern "C" fn(*mut u8, usize)>,
pub free_string: Option<unsafe extern "C" fn(*mut i8)>,
pub drop: Option<unsafe extern "C" fn(*mut c_void)>,
}Expand description
Function pointer types for data source plugins
Fields§
§init: Option<unsafe extern "C" fn(*const u8, usize) -> *mut c_void>Initialize the data source with configuration.
config: MessagePack-encoded configuration object
Returns: opaque instance pointer, or null on error
get_query_schema: Option<unsafe extern "C" fn(*mut c_void) -> *const QuerySchema>Get the query schema for this data source. Returns a pointer to the QuerySchema struct (must remain valid for plugin lifetime).
get_output_schema: Option<unsafe extern "C" fn(*mut c_void) -> *const OutputSchema>Get the output schema for this data source. Returns a pointer to the OutputSchema struct (must remain valid for plugin lifetime).
get_source_schema: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, *mut *mut u8, *mut usize) -> i32>Query the data schema for a specific source.
Unlike get_output_schema which returns a static schema for the plugin,
this function returns the dynamic schema for a specific data source.
This enables schema discovery at runtime.
source_id: The source identifier (e.g., table name, symbol, device ID)
out_ptr: Output pointer to MessagePack-encoded PluginSchema
out_len: Output length of the data
The returned PluginSchema (MessagePack) has structure:
{
"columns": [
{ "name": "timestamp", "data_type": "Timestamp" },
{ "name": "value", "data_type": "Number" }
],
"timestamp_column": "timestamp"
}Returns: 0 on success, non-zero error code on failure
Caller must free the output buffer with free_buffer.
validate_query: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, *mut *mut i8) -> i32>Validate a query before execution.
query: MessagePack-encoded query parameters
out_error: On error, write error message pointer here (caller must free with free_string)
Returns: 0 on success, non-zero error code on failure
load: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, *mut *mut u8, *mut usize) -> i32>Load historical data (JSON/MessagePack format - legacy).
query: MessagePack-encoded query parameters
out_ptr: Output pointer to MessagePack-encoded Series data
out_len: Output length of the data
Returns: 0 on success, non-zero error code on failure
Caller must free the output buffer with free_buffer.
load_binary: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, u8, Option<unsafe extern "C" fn(u8, u64, u64, u64, *mut c_void) -> i32>, *mut c_void, *mut *mut u8, *mut usize) -> i32>Load historical data in binary columnar format (ABI v2).
High-performance data loading that bypasses JSON serialization.
Returns binary data in the format defined by binary_format module
that can be directly mapped to SeriesStorage.
§Arguments
instance: Plugin instancequery: MessagePack-encoded query parametersquery_len: Length of query datagranularity: Progress reporting granularity (0=Coarse, 1=Fine)progress_callback: Optional callback for progress reportingprogress_user_data: User data passed to progress callbackout_ptr: Output pointer to binary columnar dataout_len: Output length of the data
Returns: 0 on success, non-zero error code on failure
Caller must free the output buffer with free_buffer.
subscribe: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize, unsafe extern "C" fn(*const u8, usize, *mut c_void), *mut c_void) -> u64>Subscribe to streaming data.
query: MessagePack-encoded query parameters
callback: Called for each data point (data_ptr, data_len, user_data)
callback_data: User data passed to callback
Returns: subscription ID on success, 0 on failure
unsubscribe: Option<unsafe extern "C" fn(*mut c_void, u64) -> i32>Unsubscribe from streaming data.
subscription_id: ID returned by subscribe
Returns: 0 on success, non-zero on failure
free_buffer: Option<unsafe extern "C" fn(*mut u8, usize)>Free a buffer allocated by load.
free_string: Option<unsafe extern "C" fn(*mut i8)>Free an error string allocated by validate_query.
drop: Option<unsafe extern "C" fn(*mut c_void)>Cleanup and destroy the instance.