mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
Start go/rust bindings
This commit is contained in:
parent
a2c207347e
commit
2572aa1413
7 changed files with 262 additions and 0 deletions
26
bindings/rust/src/lib.rs
Normal file
26
bindings/rust/src/lib.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#[link(name = "sqlite_vec0")]
|
||||
extern "C" {
|
||||
pub fn sqlite3_vec_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(std::mem::transmute(sqlite3_vec_init as *const ())));
|
||||
}
|
||||
|
||||
let conn = Connection::open_in_memory().unwrap();
|
||||
|
||||
let result: String = conn
|
||||
.query_row("select vec_version()", [], |x| x.get(0))
|
||||
.unwrap();
|
||||
|
||||
assert!(result.starts_with("v"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue