pub trait SqliteVectorStoreTable:
Send
+ Sync
+ Clone {
// Required methods
fn name() -> &'static str;
fn schema() -> Vec<Column>;
fn id(&self) -> String;
fn column_values(&self) -> Vec<(&'static str, Box<dyn ColumnValue>)>;
}
Expand description
Example of a document type that can be used with SqliteVectorStore
use rig::Embed;
use serde::Deserialize;
use rig_sqlite::{Column, ColumnValue, SqliteVectorStoreTable};
#[derive(Embed, Clone, Debug, Deserialize)]
struct Document {
id: String,
#[embed]
content: String,
}
impl SqliteVectorStoreTable for Document {
fn name() -> &'static str {
"documents"
}
fn schema() -> Vec<Column> {
vec![
Column::new("id", "TEXT PRIMARY KEY"),
Column::new("content", "TEXT"),
]
}
fn id(&self) -> String {
self.id.clone()
}
fn column_values(&self) -> Vec<(&'static str, Box<dyn ColumnValue>)> {
vec![
("id", Box::new(self.id.clone())),
("content", Box::new(self.content.clone())),
]
}
}
Required Methods§
fn name() -> &'static str
fn schema() -> Vec<Column>
fn id(&self) -> String
fn column_values(&self) -> Vec<(&'static str, Box<dyn ColumnValue>)>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.