llm_chain/document_stores/
document_store.rs

1use std::collections::HashMap;
2
3use crate::schema::Document;
4
5use async_trait::async_trait;
6use serde::{de::DeserializeOwned, Serialize};
7
8#[async_trait]
9pub trait DocumentStore<T, M>
10where
11    T: Send + Sync,
12    M: Serialize + DeserializeOwned + Send + Sync,
13{
14    type Error: std::fmt::Debug + std::error::Error + DocumentStoreError;
15
16    async fn get(&self, id: &T) -> Result<Option<Document<M>>, Self::Error>;
17
18    async fn next_id(&self) -> Result<T, Self::Error>;
19
20    async fn insert(&mut self, documents: &HashMap<T, Document<M>>) -> Result<(), Self::Error>;
21}
22
23pub trait DocumentStoreError {}