@@ -11,38 +11,10 @@ use crate::{
11
11
api,
12
12
constants:: { SQLITE_INTERNAL , SQLITE_OKAY } ,
13
13
errors:: { Error , ErrorKind , Result } ,
14
- ext:: sqlite3ext_create_function_v2,
14
+ ext:: sqlite3ext_create_function_v2, FunctionFlags ,
15
15
} ;
16
16
use sqlite3ext_sys:: { sqlite3, sqlite3_context, sqlite3_user_data, sqlite3_value} ;
17
17
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
-
46
18
fn create_function_v2 (
47
19
db : * mut sqlite3 ,
48
20
name : & str ,
@@ -53,14 +25,15 @@ fn create_function_v2(
53
25
x_step : Option < unsafe extern "C" fn ( * mut sqlite3_context , i32 , * mut * mut sqlite3_value ) > ,
54
26
x_final : Option < unsafe extern "C" fn ( * mut sqlite3_context ) > ,
55
27
destroy : Option < unsafe extern "C" fn ( * mut c_void ) > ,
56
- ) -> Result < ( ) > {
28
+ ) -> Result < ( ) >
29
+ {
57
30
let cname = CString :: new ( name) ?;
58
31
let result = unsafe {
59
32
sqlite3ext_create_function_v2 (
60
33
db,
61
34
cname. as_ptr ( ) ,
62
35
num_args,
63
- func_flags. bits ,
36
+ func_flags. bits ( ) ,
64
37
p_app,
65
38
x_func,
66
39
x_step,
@@ -240,3 +213,4 @@ where
240
213
241
214
x_func_wrapper :: < F >
242
215
}
216
+
0 commit comments