1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Constants and version information for the FFI operator API
/// Current API version
///
/// This version must be incremented when making breaking changes to the FFI interface.
/// Operators compiled against different API versions will be rejected.
pub const CURRENT_API: u32 = 1;
/// Magic number to identify valid FFI operator libraries
///
/// Libraries must export a `ffi_operator_magic` symbol that returns this value
/// to be recognized as valid FFI operators.
pub const OPERATOR_MAGIC: u32 = 231123;
/// Function signature for the magic number export
///
/// FFI operator libraries must export this function to be recognized as valid operators.
pub type FFIOperatorMagicFn = extern "C" fn ;
// =============================
// FFI Return Codes
// =============================
/// FFI return code: Operation succeeded, value found, or iterator has next item
pub const FFI_OK: i32 = 0;
/// FFI return code: Query succeeded but entity doesn't exist
pub const FFI_NOT_FOUND: i32 = 1;
/// FFI return code: Iterator has no more items (alias for FFI_NOT_FOUND)
pub const FFI_END_OF_ITERATION: i32 = 1;
/// FFI error code: Null pointer passed as parameter
pub const FFI_ERROR_NULL_PTR: i32 = -1;
/// FFI error code: Internal error during operation (transaction error, etc.)
pub const FFI_ERROR_INTERNAL: i32 = -2;
/// FFI error code: Memory allocation failed
pub const FFI_ERROR_ALLOC: i32 = -3;
/// FFI error code: Invalid UTF-8 in string parameter
pub const FFI_ERROR_INVALID_UTF8: i32 = -4;
/// FFI error code: Failed to marshal Rust type to FFI struct
pub const FFI_ERROR_MARSHAL: i32 = -5;
// =============================
// Operator Capabilities
// =============================
/// Capability: Operator can process inserts
pub const CAPABILITY_INSERT: u32 = 1 << 0; // 0x01
/// Capability: Operator can process updates
pub const CAPABILITY_UPDATE: u32 = 1 << 1; // 0x02
/// Capability: Operator can process deletes
pub const CAPABILITY_DELETE: u32 = 1 << 2; // 0x04
/// Capability: Operator supports get_rows(), which is required for join and window flows
pub const CAPABILITY_GET_ROWS: u32 = 1 << 3; // 0x08
/// Capability: Operator can drop data without cascading change
pub const CAPABILITY_DROP: u32 = 1 << 4; // 0x10
/// Capability: Operator wants periodic tick() callbacks
pub const CAPABILITY_TICK: u32 = 1 << 5; // 0x20
/// All standard capabilities (Insert + Update + Delete + GetRows)
pub const CAPABILITY_ALL_STANDARD: u32 =
CAPABILITY_INSERT | CAPABILITY_UPDATE | CAPABILITY_DELETE | CAPABILITY_GET_ROWS;
/// Helper to check if a capability is set
///
/// # Example
/// ```
/// use reifydb_flow_operator_abi::*;
///
/// let caps = CAPABILITY_INSERT | CAPABILITY_UPDATE;
/// assert!(has_capability(caps, CAPABILITY_INSERT));
/// assert!(has_capability(caps, CAPABILITY_UPDATE));
/// assert!(!has_capability(caps, CAPABILITY_DELETE));
/// ```
pub const