pub trait ChunkedDocumentStoreTrait: Send + Sync {
Show 18 methods
// Required methods
fn add_parent_document<'life0, 'async_trait>(
&'life0 self,
document: Document,
chunk_size: usize,
) -> Pin<Box<dyn Future<Output = Result<(String, Vec<String>), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn add_parent_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
chunk_size: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<String>)>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_parent_document<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_chunk_document<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_chunks_for_parent<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_chunk_documents_for_parent<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn delete_parent_document<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn parent_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn chunk_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_all_chunks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn add_parent_document_blocking(
&self,
document: Document,
chunk_size: usize,
) -> Result<(String, Vec<String>), VectorStoreError>;
fn get_parent_document_blocking(
&self,
parent_id: &str,
) -> Result<Option<Document>, VectorStoreError>;
fn get_chunk_blocking(
&self,
chunk_id: &str,
) -> Result<Option<ChunkDocument>, VectorStoreError>;
fn blocking_get_chunks_for_parent(
&self,
parent_id: &str,
) -> Result<Vec<ChunkDocument>, VectorStoreError>;
// Provided methods
fn save<'life0, 'async_trait>(
&'life0 self,
_path: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
fn load<'async_trait>(
_path: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, VectorStoreError>> + Send + 'async_trait>>
where Self: Sized + 'async_trait { ... }
}Expand description
支持 Parent-Child 结构的文档存储 trait
此 trait 定义了回表存储的统一接口,支持:
- MongoDB(生产环境)
- InMemory(开发/测试)
- Redis(缓存层,预留)
- SQLite(本地存储,预留)
Required Methods§
Sourcefn add_parent_document<'life0, 'async_trait>(
&'life0 self,
document: Document,
chunk_size: usize,
) -> Pin<Box<dyn Future<Output = Result<(String, Vec<String>), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn add_parent_document<'life0, 'async_trait>(
&'life0 self,
document: Document,
chunk_size: usize,
) -> Pin<Box<dyn Future<Output = Result<(String, Vec<String>), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Sourcefn add_parent_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
chunk_size: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<String>)>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn add_parent_documents<'life0, 'async_trait>(
&'life0 self,
documents: Vec<Document>,
chunk_size: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Vec<String>)>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
批量添加 Parent 文档
Sourcefn get_parent_document<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_parent_document<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
获取 Parent 文档
Sourcefn get_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
获取单个 Chunk
Sourcefn get_chunk_document<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_chunk_document<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
获取单个 Chunk(转为 Document)
Sourcefn get_chunks_for_parent<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_chunks_for_parent<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
获取 Parent 的所有 Chunks
Sourcefn get_chunk_documents_for_parent<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_chunk_documents_for_parent<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
获取 Parent 的所有 Chunks(转为 Document)
Sourcefn delete_parent_document<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete_parent_document<'life0, 'life1, 'async_trait>(
&'life0 self,
parent_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
删除 Parent 文档及其所有 Chunks
Sourcefn parent_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn parent_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
获取 Parent 文档数量
Sourcefn chunk_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn chunk_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
获取 Chunk 文档数量
Sourcefn get_all_chunks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_all_chunks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChunkDocument>, VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
获取所有 Chunks
Sourcefn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
清空所有数据
Sourcefn add_parent_document_blocking(
&self,
document: Document,
chunk_size: usize,
) -> Result<(String, Vec<String>), VectorStoreError>
fn add_parent_document_blocking( &self, document: Document, chunk_size: usize, ) -> Result<(String, Vec<String>), VectorStoreError>
添加 Parent 文档(阻塞版本)
Sourcefn get_parent_document_blocking(
&self,
parent_id: &str,
) -> Result<Option<Document>, VectorStoreError>
fn get_parent_document_blocking( &self, parent_id: &str, ) -> Result<Option<Document>, VectorStoreError>
获取 Parent 文档(阻塞版本)
Sourcefn get_chunk_blocking(
&self,
chunk_id: &str,
) -> Result<Option<ChunkDocument>, VectorStoreError>
fn get_chunk_blocking( &self, chunk_id: &str, ) -> Result<Option<ChunkDocument>, VectorStoreError>
获取单个 Chunk(阻塞版本)
Sourcefn blocking_get_chunks_for_parent(
&self,
parent_id: &str,
) -> Result<Vec<ChunkDocument>, VectorStoreError>
fn blocking_get_chunks_for_parent( &self, parent_id: &str, ) -> Result<Vec<ChunkDocument>, VectorStoreError>
获取 Parent 的所有 Chunks(阻塞版本)
Provided Methods§
Sourcefn save<'life0, 'async_trait>(
&'life0 self,
_path: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn save<'life0, 'async_trait>(
&'life0 self,
_path: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<(), VectorStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
持久化存储(可选实现)
fn load<'async_trait>(
_path: impl AsRef<Path> + Send + 'async_trait,
) -> Pin<Box<dyn Future<Output = Result<Self, VectorStoreError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".