pub trait DocumentSourcePort: Send + Sync {
// Required methods
fn read_documents<'life0, 'async_trait>(
&'life0 self,
query: DocumentQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn source_name(&self) -> &str;
}Expand description
Port: read documents from the local file system.
Implementations handle file enumeration, glob filtering, and content
reading. Binary files (PDFs, images) should be base64-encoded in the
content field and can be further processed by the multimodal adapter.
§Example
use stygian_graph::ports::document_source::{DocumentSourcePort, DocumentQuery, Document};
use stygian_graph::domain::error::Result;
use async_trait::async_trait;
use std::path::PathBuf;
struct MockDocs;
#[async_trait]
impl DocumentSourcePort for MockDocs {
async fn read_documents(&self, query: DocumentQuery) -> Result<Vec<Document>> {
Ok(vec![Document {
path: query.path,
content: "hello".into(),
mime_type: Some("text/plain".into()),
size_bytes: 5,
}])
}
fn source_name(&self) -> &str {
"mock-docs"
}
}Required Methods§
Sourcefn read_documents<'life0, 'async_trait>(
&'life0 self,
query: DocumentQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_documents<'life0, 'async_trait>(
&'life0 self,
query: DocumentQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<Document>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read documents matching the query.
§Arguments
query- Path, recursion flag, and optional glob filter
§Returns
Ok(Vec<Document>)- Matched documents with contentErr(StygianError)- I/O or permission error
§Example
let query = DocumentQuery {
path: PathBuf::from("data/report.json"),
recursive: false,
glob_pattern: None,
};
let docs = source.read_documents(query).await.unwrap();