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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//! Raw FFI declarations for the native library
//!
//! This module contains the low-level FFI function declarations
//! that map to the C ABI exposed by the .NET AOT library.
//!
//! These functions should not be called directly - use the safe
//! wrappers in the `validator` module instead.
use c_int;
/// Type alias for FFI function pointers
pub type FfiResult = c_int;
/// FFI function type: Initialize the library
///
/// Returns 0 on success, negative error code on failure.
pub type KqlInitFn = unsafe extern "C" fn ;
/// FFI function type: Cleanup the library
pub type KqlCleanupFn = unsafe extern "C" fn;
/// FFI function type: Validate KQL syntax
///
/// # Arguments
/// * `query` - Pointer to UTF-8 encoded query string
/// * `query_len` - Length of the query in bytes
/// * `output` - Pointer to output buffer for JSON result
/// * `output_max_len` - Maximum size of output buffer
///
/// # Returns
/// * `> 0` - Success, value is the length of JSON written to output
/// * `0` - Success, empty result
/// * `-1` - Buffer too small
/// * `-2` - Parse error in input
/// * `-3` - Internal error
pub type KqlValidateSyntaxFn =
unsafe extern "C" fn ;
/// FFI function type: Validate KQL with schema
///
/// # Arguments
/// * `query` - Pointer to UTF-8 encoded query string
/// * `query_len` - Length of the query in bytes
/// * `schema_json` - Pointer to UTF-8 encoded JSON schema
/// * `schema_len` - Length of the schema JSON in bytes
/// * `output` - Pointer to output buffer for JSON result
/// * `output_max_len` - Maximum size of output buffer
///
/// # Returns
/// Same as `KqlValidateSyntaxFn`
pub type KqlValidateWithSchemaFn = unsafe extern "C" fn ;
/// FFI function type: Get the last error message
///
/// # Arguments
/// * `output` - Pointer to output buffer for error message
/// * `output_max_len` - Maximum size of output buffer
///
/// # Returns
/// * `> 0` - Length of error message written
/// * `0` - No error message available
/// * `-1` - Buffer too small
pub type KqlGetLastErrorFn = unsafe extern "C" fn ;
/// FFI function type: Get completions at cursor position
///
/// # Arguments
/// * `query` - Pointer to UTF-8 encoded query string
/// * `query_len` - Length of the query in bytes
/// * `cursor_pos` - Cursor position (0-based character offset)
/// * `schema_json` - Pointer to UTF-8 encoded JSON schema (can be null)
/// * `schema_len` - Length of the schema JSON in bytes (0 if null)
/// * `output` - Pointer to output buffer for JSON result
/// * `output_max_len` - Maximum size of output buffer
///
/// # Returns
/// Same as `KqlValidateSyntaxFn`
pub type KqlGetCompletionsFn = unsafe extern "C" fn ;
/// FFI function type: Get syntax classifications
///
/// # Arguments
/// * `query` - Pointer to UTF-8 encoded query string
/// * `query_len` - Length of the query in bytes
/// * `output` - Pointer to output buffer for JSON result
/// * `output_max_len` - Maximum size of output buffer
///
/// # Returns
/// Same as `KqlValidateSyntaxFn`
pub type KqlGetClassificationsFn =
unsafe extern "C" fn ;
/// Symbol names in the native library
/// Return codes from FFI functions
/// Default buffer size for FFI output (64KB)
pub const DEFAULT_BUFFER_SIZE: usize = 64 * 1024;
/// Maximum buffer size for FFI output (4MB)
pub const MAX_BUFFER_SIZE: usize = 4 * 1024 * 1024;