1#![allow(non_camel_case_types)]
20#![allow(non_upper_case_globals)]
21#![allow(non_snake_case)]
22
23pub const true_: u32 = 1;
25
26pub const false_: u32 = 0;
28
29pub const __bool_true_false_are_defined: u32 = 1;
31
32#[repr(C)]
35#[non_exhaustive]
36#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
37pub enum Item_result {
38 INVALID_RESULT = -1,
40
41 STRING_RESULT = 0,
43
44 REAL_RESULT = 1,
46
47 INT_RESULT = 2,
49
50 ROW_RESULT = 3,
52
53 DECIMAL_RESULT = 4,
55}
56
57impl TryFrom<i32> for Item_result {
58 type Error = String;
59
60 fn try_from(value: i32) -> Result<Self, Self::Error> {
61 match value {
62 x if x == Self::INVALID_RESULT as i32 => Ok(Self::INVALID_RESULT),
63 x if x == Self::STRING_RESULT as i32 => Ok(Self::STRING_RESULT),
64 x if x == Self::REAL_RESULT as i32 => Ok(Self::REAL_RESULT),
65 x if x == Self::INT_RESULT as i32 => Ok(Self::INT_RESULT),
66 x if x == Self::ROW_RESULT as i32 => Ok(Self::ROW_RESULT),
67 x if x == Self::DECIMAL_RESULT as i32 => Ok(Self::DECIMAL_RESULT),
68 _ => Err(format!("invalid arg type {value} received")),
69 }
70 }
71}
72
73#[repr(C)]
75#[derive(Debug, Clone)]
76pub struct UDF_ARGS {
77 pub arg_count: ::std::ffi::c_uint,
79
80 pub arg_types: *mut Item_result,
84
85 pub args: *const *const ::std::ffi::c_char,
88
89 pub lengths: *const ::std::ffi::c_ulong,
91
92 pub maybe_null: *const ::std::ffi::c_char,
94
95 pub attributes: *const *const ::std::ffi::c_char,
98
99 pub attribute_lengths: *const ::std::ffi::c_ulong,
101
102 pub extension: *const ::std::ffi::c_void,
104}
105
106#[repr(C)]
108#[derive(Debug, Clone)]
109pub struct UDF_INIT {
110 pub maybe_null: bool,
112
113 pub decimals: ::std::ffi::c_uint,
115
116 pub max_length: ::std::ffi::c_ulong,
118
119 pub ptr: *mut ::std::ffi::c_char,
121
122 pub const_item: bool,
124
125 pub extension: *mut ::std::ffi::c_void,
127}
128
129#[repr(u32)]
131#[non_exhaustive]
132#[derive(Debug, Clone, Hash, PartialEq, Eq)]
133pub enum Item_udftype {
134 UDFTYPE_FUNCTION = 1,
135 UDFTYPE_AGGREGATE = 2,
136}
137
138pub type Udf_func_init = Option<
140 unsafe extern "C" fn(
141 initid: *mut UDF_INIT,
142 args: *mut UDF_ARGS,
143 message: *mut ::std::ffi::c_char,
144 ) -> bool,
145>;
146
147pub type Udf_func_deinit = Option<unsafe extern "C" fn(arg1: *mut UDF_INIT)>;
149
150pub type Udf_func_add = Option<
152 unsafe extern "C" fn(
153 initid: *mut UDF_INIT,
154 args: *const UDF_ARGS,
155 is_null: *mut ::std::ffi::c_uchar,
156 error: *mut ::std::ffi::c_uchar,
157 ),
158>;
159
160pub type Udf_func_clear = Option<
162 unsafe extern "C" fn(
163 initid: *mut UDF_INIT,
164 is_null: *mut ::std::ffi::c_uchar,
165 error: *mut ::std::ffi::c_uchar,
166 ),
167>;
168
169pub type Udf_func_double = Option<
171 unsafe extern "C" fn(
172 initid: *mut UDF_INIT,
173 args: *const UDF_ARGS,
174 is_null: *mut ::std::ffi::c_uchar,
175 error: *mut ::std::ffi::c_uchar,
176 ) -> ::std::ffi::c_double,
177>;
178
179pub type Udf_func_longlong = Option<
181 unsafe extern "C" fn(
182 initid: *mut UDF_INIT,
183 args: *const UDF_ARGS,
184 is_null: *mut ::std::ffi::c_uchar,
185 error: *mut ::std::ffi::c_uchar,
186 ) -> ::std::ffi::c_longlong,
187>;
188
189pub type Udf_func_string = Option<
191 unsafe extern "C" fn(
192 initid: *mut UDF_INIT,
193 args: *const UDF_ARGS,
194 result: *mut ::std::ffi::c_char,
195 length: *mut ::std::ffi::c_ulong,
196 is_null: *mut ::std::ffi::c_uchar,
197 error: *mut ::std::ffi::c_uchar,
198 ) -> *mut ::std::ffi::c_char,
199>;
200
201pub type Udf_func_any = Option<unsafe extern "C" fn()>;
203
204#[cfg(test)]
205mod tests {
206
207 use super::*;
208
209 #[test]
210 fn bindgen_test_layout_UDF_ARGS() {
211 assert_eq!(
212 ::std::mem::size_of::<UDF_ARGS>(),
213 64usize,
214 concat!("Size of: ", stringify!(UDF_ARGS))
215 );
216 assert_eq!(
217 ::std::mem::align_of::<UDF_ARGS>(),
218 8usize,
219 concat!("Alignment of ", stringify!(UDF_ARGS))
220 );
221 fn test_field_arg_count() {
222 assert_eq!(
223 unsafe {
224 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
225 let ptr = uninit.as_ptr();
226 ::std::ptr::addr_of!((*ptr).arg_count) as usize - ptr as usize
227 },
228 0usize,
229 concat!(
230 "Offset of field: ",
231 stringify!(UDF_ARGS),
232 "::",
233 stringify!(arg_count)
234 )
235 );
236 }
237 test_field_arg_count();
238 fn test_field_arg_type() {
239 assert_eq!(
240 unsafe {
241 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
242 let ptr = uninit.as_ptr();
243 ::std::ptr::addr_of!((*ptr).arg_types) as usize - ptr as usize
244 },
245 8usize,
246 concat!(
247 "Offset of field: ",
248 stringify!(UDF_ARGS),
249 "::",
250 stringify!(arg_type)
251 )
252 );
253 }
254 test_field_arg_type();
255 fn test_field_args() {
256 assert_eq!(
257 unsafe {
258 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
259 let ptr = uninit.as_ptr();
260 ::std::ptr::addr_of!((*ptr).args) as usize - ptr as usize
261 },
262 16usize,
263 concat!(
264 "Offset of field: ",
265 stringify!(UDF_ARGS),
266 "::",
267 stringify!(args)
268 )
269 );
270 }
271 test_field_args();
272 fn test_field_lengths() {
273 assert_eq!(
274 unsafe {
275 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
276 let ptr = uninit.as_ptr();
277 ::std::ptr::addr_of!((*ptr).lengths) as usize - ptr as usize
278 },
279 24usize,
280 concat!(
281 "Offset of field: ",
282 stringify!(UDF_ARGS),
283 "::",
284 stringify!(lengths)
285 )
286 );
287 }
288 test_field_lengths();
289 fn test_field_maybe_null() {
290 assert_eq!(
291 unsafe {
292 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
293 let ptr = uninit.as_ptr();
294 ::std::ptr::addr_of!((*ptr).maybe_null) as usize - ptr as usize
295 },
296 32usize,
297 concat!(
298 "Offset of field: ",
299 stringify!(UDF_ARGS),
300 "::",
301 stringify!(maybe_null)
302 )
303 );
304 }
305 test_field_maybe_null();
306 fn test_field_attributes() {
307 assert_eq!(
308 unsafe {
309 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
310 let ptr = uninit.as_ptr();
311 ::std::ptr::addr_of!((*ptr).attributes) as usize - ptr as usize
312 },
313 40usize,
314 concat!(
315 "Offset of field: ",
316 stringify!(UDF_ARGS),
317 "::",
318 stringify!(attributes)
319 )
320 );
321 }
322 test_field_attributes();
323 fn test_field_attribute_lengths() {
324 assert_eq!(
325 unsafe {
326 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
327 let ptr = uninit.as_ptr();
328 ::std::ptr::addr_of!((*ptr).attribute_lengths) as usize - ptr as usize
329 },
330 48usize,
331 concat!(
332 "Offset of field: ",
333 stringify!(UDF_ARGS),
334 "::",
335 stringify!(attribute_lengths)
336 )
337 );
338 }
339 test_field_attribute_lengths();
340 fn test_field_extension() {
341 assert_eq!(
342 unsafe {
343 let uninit = ::std::mem::MaybeUninit::<UDF_ARGS>::uninit();
344 let ptr = uninit.as_ptr();
345 ::std::ptr::addr_of!((*ptr).extension) as usize - ptr as usize
346 },
347 56usize,
348 concat!(
349 "Offset of field: ",
350 stringify!(UDF_ARGS),
351 "::",
352 stringify!(extension)
353 )
354 );
355 }
356 test_field_extension();
357 }
358
359 #[test]
360 fn bindgen_test_layout_UDF_INIT() {
361 assert_eq!(
362 ::std::mem::size_of::<UDF_INIT>(),
363 40usize,
364 concat!("Size of: ", stringify!(UDF_INIT))
365 );
366 assert_eq!(
367 ::std::mem::align_of::<UDF_INIT>(),
368 8usize,
369 concat!("Alignment of ", stringify!(UDF_INIT))
370 );
371 fn test_field_maybe_null() {
372 assert_eq!(
373 unsafe {
374 let uninit = ::std::mem::MaybeUninit::<UDF_INIT>::uninit();
375 let ptr = uninit.as_ptr();
376 ::std::ptr::addr_of!((*ptr).maybe_null) as usize - ptr as usize
377 },
378 0usize,
379 concat!(
380 "Offset of field: ",
381 stringify!(UDF_INIT),
382 "::",
383 stringify!(maybe_null)
384 )
385 );
386 }
387 test_field_maybe_null();
388 fn test_field_decimals() {
389 assert_eq!(
390 unsafe {
391 let uninit = ::std::mem::MaybeUninit::<UDF_INIT>::uninit();
392 let ptr = uninit.as_ptr();
393 ::std::ptr::addr_of!((*ptr).decimals) as usize - ptr as usize
394 },
395 4usize,
396 concat!(
397 "Offset of field: ",
398 stringify!(UDF_INIT),
399 "::",
400 stringify!(decimals)
401 )
402 );
403 }
404 test_field_decimals();
405 fn test_field_max_length() {
406 assert_eq!(
407 unsafe {
408 let uninit = ::std::mem::MaybeUninit::<UDF_INIT>::uninit();
409 let ptr = uninit.as_ptr();
410 ::std::ptr::addr_of!((*ptr).max_length) as usize - ptr as usize
411 },
412 8usize,
413 concat!(
414 "Offset of field: ",
415 stringify!(UDF_INIT),
416 "::",
417 stringify!(max_length)
418 )
419 );
420 }
421 test_field_max_length();
422 fn test_field_ptr() {
423 assert_eq!(
424 unsafe {
425 let uninit = ::std::mem::MaybeUninit::<UDF_INIT>::uninit();
426 let ptr = uninit.as_ptr();
427 ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize
428 },
429 16usize,
430 concat!(
431 "Offset of field: ",
432 stringify!(UDF_INIT),
433 "::",
434 stringify!(ptr)
435 )
436 );
437 }
438 test_field_ptr();
439 fn test_field_const_item() {
440 assert_eq!(
441 unsafe {
442 let uninit = ::std::mem::MaybeUninit::<UDF_INIT>::uninit();
443 let ptr = uninit.as_ptr();
444 ::std::ptr::addr_of!((*ptr).const_item) as usize - ptr as usize
445 },
446 24usize,
447 concat!(
448 "Offset of field: ",
449 stringify!(UDF_INIT),
450 "::",
451 stringify!(const_item)
452 )
453 );
454 }
455 test_field_const_item();
456 fn test_field_extension() {
457 assert_eq!(
458 unsafe {
459 let uninit = ::std::mem::MaybeUninit::<UDF_INIT>::uninit();
460 let ptr = uninit.as_ptr();
461 ::std::ptr::addr_of!((*ptr).extension) as usize - ptr as usize
462 },
463 32usize,
464 concat!(
465 "Offset of field: ",
466 stringify!(UDF_INIT),
467 "::",
468 stringify!(extension)
469 )
470 );
471 }
472 test_field_extension();
473 }
474}