sz_rust_sdk/ffi/
bindings.rs

1//! Low-level FFI bindings to the native Senzing library
2//!
3//! These bindings match the native function calls used by the official C# SDK,
4//! including the use of helper functions where available.
5
6use libc::{c_char, c_longlong};
7
8/// Result structure for helper functions that return pointers
9#[doc(hidden)]
10#[repr(C)]
11#[derive(Debug)]
12pub struct SzPointerResult {
13    pub response: *mut c_char,
14    pub return_code: c_longlong,
15}
16
17/// Result structure for helper functions that return long values
18#[doc(hidden)]
19#[repr(C)]
20#[derive(Debug)]
21pub struct SzLongResult {
22    pub response: c_longlong,
23    pub return_code: c_longlong,
24}
25
26/// Network analysis result structure
27#[doc(hidden)]
28#[repr(C)]
29#[derive(Debug)]
30pub struct SzNetworkResult {
31    pub response: *mut c_char,
32    pub return_code: c_longlong,
33}
34
35unsafe extern "C" {
36    // Environment/Core functions
37    pub fn Sz_init(
38        module_name: *const c_char,
39        ini_params: *const c_char,
40        verbose_logging: c_longlong,
41    ) -> c_longlong;
42
43    pub fn Sz_initWithConfigID(
44        module_name: *const c_char,
45        ini_params: *const c_char,
46        config_id: c_longlong,
47        verbose_logging: c_longlong,
48    ) -> c_longlong;
49
50    pub fn Sz_reinit(config_id: c_longlong) -> c_longlong;
51
52    pub fn Sz_destroy() -> c_longlong;
53
54    // Module-specific destroy functions
55    pub fn SzConfig_destroy() -> c_longlong;
56    pub fn SzConfigMgr_destroy() -> c_longlong;
57    pub fn SzDiagnostic_destroy() -> c_longlong;
58    pub fn SzProduct_destroy() -> c_longlong;
59
60    pub fn Sz_getActiveConfigID() -> c_longlong;
61
62    // Engine functions using helper variants
63    pub fn Sz_primeEngine() -> c_longlong;
64
65    pub fn Sz_stats_helper() -> SzPointerResult;
66
67    pub fn Sz_addRecord(
68        data_source_code: *const c_char,
69        record_id: *const c_char,
70        record_definition: *const c_char,
71    ) -> c_longlong;
72
73    pub fn Sz_addRecordWithInfo_helper(
74        data_source_code: *const c_char,
75        record_id: *const c_char,
76        record_definition: *const c_char,
77        flags: c_longlong,
78    ) -> SzPointerResult;
79
80    pub fn Sz_deleteRecord(data_source_code: *const c_char, record_id: *const c_char)
81    -> c_longlong;
82
83    pub fn Sz_deleteRecordWithInfo_helper(
84        data_source_code: *const c_char,
85        record_id: *const c_char,
86        flags: c_longlong,
87    ) -> SzPointerResult;
88
89    pub fn Sz_getEntityByEntityID_helper(entity_id: c_longlong) -> SzPointerResult;
90
91    pub fn Sz_getEntityByRecordID_helper(
92        data_source_code: *const c_char,
93        record_id: *const c_char,
94    ) -> SzPointerResult;
95
96    pub fn Sz_getRecord_helper(
97        data_source_code: *const c_char,
98        record_id: *const c_char,
99        flags: c_longlong,
100    ) -> SzPointerResult;
101
102    pub fn Sz_getRecordPreview_helper(
103        record_definition: *const c_char,
104        flags: c_longlong,
105    ) -> SzPointerResult;
106
107    pub fn Sz_searchByAttributes_helper(attributes: *const c_char) -> SzPointerResult;
108
109    pub fn Sz_searchByAttributes_V3_helper(
110        attributes: *const c_char,
111        search_profile: *const c_char,
112        flags: c_longlong,
113    ) -> SzPointerResult;
114
115    pub fn Sz_whyEntityByEntityID_helper(
116        entity_id1: c_longlong,
117        entity_id2: c_longlong,
118        flags: c_longlong,
119    ) -> *mut c_char;
120
121    pub fn Sz_findPathByEntityID_helper(
122        start_entity_id: c_longlong,
123        end_entity_id: c_longlong,
124        max_degrees: c_longlong,
125        flags: c_longlong,
126    ) -> *mut c_char;
127
128    pub fn Sz_findNetworkByEntityID_V2_helper(
129        entity_list: *const c_char,
130        max_degrees: c_longlong,
131        build_out_degree: c_longlong,
132        max_entities: c_longlong,
133        flags: c_longlong,
134    ) -> SzNetworkResult;
135
136    pub fn Sz_exportJSONEntityReport_helper(flags: c_longlong) -> SzPointerResult;
137
138    pub fn Sz_exportCSVEntityReport_helper(
139        csv_column_list: *const c_char,
140        flags: c_longlong,
141    ) -> SzPointerResult;
142
143    pub fn Sz_fetchNext_helper(export_handle: *const c_char) -> SzPointerResult;
144
145    pub fn Sz_closeExportReport_helper(export_handle: *const c_char) -> c_longlong;
146
147    pub fn Sz_processRedoRecord() -> *mut c_char;
148
149    pub fn Sz_processRedoRecordWithInfo_helper(
150        redo_record: *const c_char,
151        flags: c_longlong,
152    ) -> SzPointerResult;
153
154    pub fn Sz_getRedoRecord_helper() -> SzPointerResult;
155
156    pub fn Sz_countRedoRecords() -> c_longlong;
157
158    // Critical missing stewardship and analysis functions for 100% C# SDK parity
159    pub fn Sz_reevaluateEntityWithInfo_helper(
160        entity_id: c_longlong,
161        flags: c_longlong,
162    ) -> SzPointerResult;
163
164    pub fn Sz_reevaluateRecordWithInfo_helper(
165        data_source_code: *const c_char,
166        record_id: *const c_char,
167        flags: c_longlong,
168    ) -> SzPointerResult;
169
170    pub fn Sz_whyRecordInEntity_helper(
171        data_source_code: *const c_char,
172        record_id: *const c_char,
173        flags: c_longlong,
174    ) -> SzPointerResult;
175
176    pub fn Sz_whyEntities_helper(
177        entity_id1: c_longlong,
178        entity_id2: c_longlong,
179        flags: c_longlong,
180    ) -> SzPointerResult;
181
182    pub fn Sz_whySearch_helper(
183        attributes: *const c_char,
184        entity_id: c_longlong,
185        search_profile: *const c_char,
186        flags: c_longlong,
187    ) -> SzPointerResult;
188
189    pub fn Sz_findInterestingEntitiesByEntityID_helper(
190        entity_id: c_longlong,
191        flags: c_longlong,
192    ) -> SzPointerResult;
193
194    pub fn Sz_findInterestingEntitiesByRecordID_helper(
195        data_source_code: *const c_char,
196        record_id: *const c_char,
197        flags: c_longlong,
198    ) -> SzPointerResult;
199
200    pub fn Sz_whyRecords_helper(
201        data_source_code1: *const c_char,
202        record_id1: *const c_char,
203        data_source_code2: *const c_char,
204        record_id2: *const c_char,
205        flags: c_longlong,
206    ) -> SzPointerResult;
207
208    pub fn Sz_howEntityByEntityID_helper(
209        entity_id: c_longlong,
210        flags: c_longlong,
211    ) -> SzPointerResult;
212
213    pub fn Sz_getVirtualEntityByRecordID_helper(
214        data_source_code: *const c_char,
215        record_id: *const c_char,
216    ) -> SzPointerResult;
217
218    // Config functions
219    pub fn SzConfig_init(
220        module_name: *const c_char,
221        ini_params: *const c_char,
222        verbose_logging: c_longlong,
223    ) -> c_longlong;
224
225    pub fn SzConfig_create_helper() -> SzPointerResult;
226
227    pub fn SzConfig_close_helper(config_handle: *const c_char) -> c_longlong;
228
229    pub fn SzConfig_load_helper(config_definition: *const c_char) -> SzPointerResult;
230
231    pub fn SzConfig_export_helper(config_handle: *const c_char) -> SzPointerResult;
232
233    pub fn SzConfig_getDataSourceRegistry_helper(config_handle: *const c_char) -> SzPointerResult;
234
235    pub fn SzConfig_registerDataSource(
236        config_handle: *const c_char,
237        data_source_code: *const c_char,
238        response: *mut *mut c_char,
239        response_size: *mut usize,
240    ) -> c_longlong;
241
242    pub fn SzConfig_registerDataSource_helper(
243        config_handle: *const c_char,
244        data_source_code: *const c_char,
245    ) -> SzPointerResult;
246
247    pub fn SzConfig_unregisterDataSource_helper(
248        config_handle: *const c_char,
249        data_source_code: *const c_char,
250    ) -> c_longlong;
251
252    // ConfigManager functions
253    pub fn SzConfigMgr_init(
254        module_name: *const c_char,
255        ini_params: *const c_char,
256        verbose_logging: c_longlong,
257    ) -> c_longlong;
258
259    pub fn SzConfigMgr_getDefaultConfigID_helper() -> SzLongResult;
260
261    pub fn SzConfigMgr_registerConfig_helper(
262        config_definition: *const c_char,
263        config_comment: *const c_char,
264    ) -> SzLongResult;
265
266    pub fn SzConfigMgr_getConfig_helper(config_id: c_longlong) -> SzPointerResult;
267
268    pub fn SzConfigMgr_getConfigRegistry_helper() -> SzPointerResult;
269
270    pub fn SzConfigMgr_replaceDefaultConfigID(
271        current_default_config_id: c_longlong,
272        new_default_config_id: c_longlong,
273    ) -> c_longlong;
274
275    pub fn SzConfigMgr_setDefaultConfigID(config_id: c_longlong) -> c_longlong;
276
277    // Diagnostic functions
278    pub fn SzDiagnostic_init(
279        module_name: *const c_char,
280        ini_params: *const c_char,
281        verbose_logging: c_longlong,
282    ) -> c_longlong;
283
284    pub fn SzDiagnostic_checkRepositoryPerformance_helper(
285        seconds_to_run: c_longlong,
286    ) -> SzPointerResult;
287
288    pub fn SzDiagnostic_getFeature_helper(feature_id: c_longlong) -> SzPointerResult;
289
290    pub fn SzDiagnostic_getRepositoryInfo_helper() -> SzPointerResult;
291
292    pub fn SzDiagnostic_purgeRepository() -> c_longlong;
293
294    // Product functions
295    pub fn SzProduct_init(
296        module_name: *const c_char,
297        ini_params: *const c_char,
298        verbose_logging: c_longlong,
299    ) -> c_longlong;
300
301    pub fn SzProduct_getLicense() -> *mut c_char;
302
303    pub fn SzProduct_getVersion() -> *mut c_char;
304
305    // Memory management
306    pub fn Sz_free(ptr: *mut c_char);
307
308    // Error handling
309    pub fn Sz_getLastException(buf: *mut c_char, length: c_longlong) -> c_longlong;
310
311    pub fn Sz_getLastExceptionCode() -> c_longlong;
312
313    pub fn Sz_clearLastException();
314
315    pub fn SzConfig_getLastException(buf: *mut c_char, length: c_longlong) -> c_longlong;
316
317    pub fn SzConfig_clearLastException();
318
319    pub fn SzConfigMgr_getLastException(buf: *mut c_char, length: c_longlong) -> c_longlong;
320
321    pub fn SzConfigMgr_clearLastException();
322
323    pub fn SzDiagnostic_getLastException(buf: *mut c_char, length: c_longlong) -> c_longlong;
324
325    pub fn SzDiagnostic_clearLastException();
326
327    pub fn SzProduct_getLastException(buf: *mut c_char, length: c_longlong) -> c_longlong;
328
329    pub fn SzProduct_clearLastException();
330}