@@ -11,38 +11,10 @@ use crate::{
1111 api,
1212 constants:: { SQLITE_INTERNAL , SQLITE_OKAY } ,
1313 errors:: { Error , ErrorKind , Result } ,
14- ext:: sqlite3ext_create_function_v2,
14+ ext:: sqlite3ext_create_function_v2, FunctionFlags ,
1515} ;
1616use sqlite3ext_sys:: { sqlite3, sqlite3_context, sqlite3_user_data, sqlite3_value} ;
1717
18- use bitflags:: bitflags;
19-
20- use sqlite3ext_sys:: {
21- SQLITE_DETERMINISTIC , SQLITE_DIRECTONLY , SQLITE_INNOCUOUS , SQLITE_SUBTYPE , SQLITE_UTF16 ,
22- SQLITE_UTF16BE , SQLITE_UTF16LE , SQLITE_UTF8 ,
23- } ;
24-
25- bitflags ! {
26- /// Represents the possible flag values that can be passed into sqlite3_create_function_v2
27- /// or sqlite3_create_window_function, as the 4th "eTextRep" parameter.
28- /// Includes both the encoding options (utf8, utf16, etc.) and function-level parameters
29- /// (deterministion, innocuous, etc.).
30- pub struct FunctionFlags : i32 {
31- const UTF8 = SQLITE_UTF8 as i32 ;
32- const UTF16LE = SQLITE_UTF16LE as i32 ;
33- const UTF16BE = SQLITE_UTF16BE as i32 ;
34- const UTF16 = SQLITE_UTF16 as i32 ;
35-
36- /// "... to signal that the function will always return the same result given the same
37- /// inputs within a single SQL statement."
38- /// <https://www.sqlite.org/c3ref/create_function.html#:~:text=ORed%20with%20SQLITE_DETERMINISTIC>
39- const DETERMINISTIC = SQLITE_DETERMINISTIC as i32 ;
40- const DIRECTONLY = SQLITE_DIRECTONLY as i32 ;
41- const SUBTYPE = SQLITE_SUBTYPE as i32 ;
42- const INNOCUOUS = SQLITE_INNOCUOUS as i32 ;
43- }
44- }
45-
4618fn create_function_v2 (
4719 db : * mut sqlite3 ,
4820 name : & str ,
@@ -53,14 +25,15 @@ fn create_function_v2(
5325 x_step : Option < unsafe extern "C" fn ( * mut sqlite3_context , i32 , * mut * mut sqlite3_value ) > ,
5426 x_final : Option < unsafe extern "C" fn ( * mut sqlite3_context ) > ,
5527 destroy : Option < unsafe extern "C" fn ( * mut c_void ) > ,
56- ) -> Result < ( ) > {
28+ ) -> Result < ( ) >
29+ {
5730 let cname = CString :: new ( name) ?;
5831 let result = unsafe {
5932 sqlite3ext_create_function_v2 (
6033 db,
6134 cname. as_ptr ( ) ,
6235 num_args,
63- func_flags. bits ,
36+ func_flags. bits ( ) ,
6437 p_app,
6538 x_func,
6639 x_step,
@@ -240,3 +213,4 @@ where
240213
241214 x_func_wrapper :: < F >
242215}
216+
0 commit comments