pub struct Engine { /* private fields */ }Expand description
The main Engine client.
Provides high-level operations for document indexing and retrieval. Uses interior mutability to allow sharing across async tasks.
§Cloning
Cloning is cheap - it only increments reference counts (Arc). All clones
share the same underlying resources.
§Thread Safety
The client is Clone + Send + Sync and can be safely shared across threads.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn builder() -> EngineBuilder
pub fn builder() -> EngineBuilder
Create a builder for custom configuration.
Sourcepub async fn index(&self, path: impl AsRef<Path>) -> Result<String>
pub async fn index(&self, path: impl AsRef<Path>) -> Result<String>
Index a document from a file path.
Returns a unique document ID.
§Errors
Returns an error if:
- The file does not exist
- The file format is not supported
- The pipeline execution fails
Sourcepub async fn index_with_options(
&self,
path: impl AsRef<Path>,
options: IndexOptions,
) -> Result<String>
pub async fn index_with_options( &self, path: impl AsRef<Path>, options: IndexOptions, ) -> Result<String>
Sourcepub async fn query(&self, doc_id: &str, question: &str) -> Result<QueryResult>
pub async fn query(&self, doc_id: &str, question: &str) -> Result<QueryResult>
Query a document.
Uses the adaptive retriever to find relevant content.
§Errors
Returns an error if:
- No workspace is configured
- The document is not found
- The retrieval fails
Sourcepub async fn query_with_context(
&self,
doc_id: &str,
question: &str,
ctx: &ClientContext,
) -> Result<QueryResult>
pub async fn query_with_context( &self, doc_id: &str, question: &str, ctx: &ClientContext, ) -> Result<QueryResult>
Query a document with context.
Allows request-specific configuration overrides.
Sourcepub fn session(&self) -> Session
pub fn session(&self) -> Session
Create a session for multi-document operations.
Sessions provide:
- Automatic caching of document trees
- Cross-document queries
- Session statistics
Sourcepub fn list_documents(&self) -> Vec<DocumentInfo>
pub fn list_documents(&self) -> Vec<DocumentInfo>
Get a list of all indexed documents.
Sourcepub fn get_structure(&self, doc_id: &str) -> Result<DocumentTree>
pub fn get_structure(&self, doc_id: &str) -> Result<DocumentTree>
Get document structure (tree).
§Errors
Returns an error if:
- No workspace is configured
- The document is not found
Sourcepub fn get_page_content(&self, doc_id: &str, pages: &str) -> Result<String>
pub fn get_page_content(&self, doc_id: &str, pages: &str) -> Result<String>
Get page content for PDFs.
§Errors
Returns an error if:
- No workspace is configured
- The document is not found
- No page content is available
Sourcepub fn load(&self, doc_id: &str) -> Result<bool>
pub fn load(&self, doc_id: &str) -> Result<bool>
Load a document from the workspace into cache.
This preloads the document into the LRU cache for faster access.
§Errors
Returns an error if no workspace is configured.
Sourcepub fn exists(&self, doc_id: &str) -> Result<bool>
pub fn exists(&self, doc_id: &str) -> Result<bool>
Check if a document exists in the workspace.
§Errors
Returns an error if no workspace is configured.
Sourcepub fn get_metadata(&self, doc_id: &str) -> Result<Option<DocumentInfo>>
pub fn get_metadata(&self, doc_id: &str) -> Result<Option<DocumentInfo>>
Sourcepub fn batch_remove(&self, doc_ids: &[&str]) -> Result<usize>
pub fn batch_remove(&self, doc_ids: &[&str]) -> Result<usize>
Remove multiple documents from the workspace.
Returns the number of documents successfully removed.
§Errors
Returns an error if no workspace is configured.
Sourcepub fn clear(&self) -> Result<usize>
pub fn clear(&self) -> Result<usize>
Remove all documents from the workspace.
Returns the number of documents removed.
§Errors
Returns an error if no workspace is configured.
Sourcepub fn indexer(&self) -> &IndexerClient
pub fn indexer(&self) -> &IndexerClient
Get the indexer client.
Sourcepub fn retriever(&self) -> &RetrieverClient
pub fn retriever(&self) -> &RetrieverClient
Get the retriever client.
Sourcepub fn workspace(&self) -> Option<&WorkspaceClient>
pub fn workspace(&self) -> Option<&WorkspaceClient>
Get the workspace client.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more