-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
lib.rs
43 lines (35 loc) · 1.02 KB
/
lib.rs
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
#[cfg(feature = "vector")]
#[link(name = "sqlite_vector0")]
extern "C" {
pub fn sqlite3_vector_init();
}
#[cfg(feature = "vss")]
#[link(name = "sqlite_vss0")]
extern "C" {
pub fn sqlite3_vss_init();
}
#[cfg(test)]
mod tests {
use super::*;
use rusqlite::{ffi::sqlite3_auto_extension, Connection};
#[test]
fn test_rusqlite_auto_extension() {
unsafe {
sqlite3_auto_extension(Some(sqlite3_vector_init));
sqlite3_auto_extension(Some(sqlite3_vss_init));
}
let conn = Connection::open_in_memory().unwrap();
let result: String = conn
.query_row("select vss_version()", [], |row| row.get(0))
.unwrap();
assert_eq!(result, format!("v{}", env!("CARGO_PKG_VERSION")));
let result: String = conn
.query_row(
"select vector_to_json(?)",
[[0x00, 0x00, 0x28, 0x42]],
|row| row.get(0),
)
.unwrap();
assert_eq!(result, "[42.0]");
}
}