pub trait Source:
Send
+ Sync
+ Debug {
Show 19 methods
// Required methods
fn id(&self) -> &str;
fn name(&self) -> &str;
// Provided methods
fn capabilities(&self) -> SourceCapabilities { ... }
fn supports_search(&self) -> bool { ... }
fn supports_download(&self) -> bool { ... }
fn supports_read(&self) -> bool { ... }
fn supports_citations(&self) -> bool { ... }
fn supports_doi_lookup(&self) -> bool { ... }
fn supports_author_search(&self) -> bool { ... }
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn search_by_author<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_author: &'life1 str,
_max_results: usize,
_year: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn download<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadResult, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ReadRequest,
) -> Pin<Box<dyn Future<Output = Result<ReadResult, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_citations<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_references<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_related<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_by_doi<'life0, 'life1, 'async_trait>(
&'life0 self,
_doi: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Paper, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Paper, SourceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn validate_id(&self, _id: &str) -> Result<(), SourceError> { ... }
}Expand description
The Source trait defines the interface for all research source plugins.
§Implementing a New Source
To add a new research source:
- Create a new struct that implements
Source - Implement the required methods (at minimum
id,name, andsearch) - Implement optional methods if the source supports them
- Add the source to
SourceRegistry::new()or register it dynamically
Required Methods§
Provided Methods§
Sourcefn capabilities(&self) -> SourceCapabilities
fn capabilities(&self) -> SourceCapabilities
Describe the capabilities of this source
Sourcefn supports_search(&self) -> bool
fn supports_search(&self) -> bool
Whether this source supports search
Sourcefn supports_download(&self) -> bool
fn supports_download(&self) -> bool
Whether this source supports downloading PDFs
Sourcefn supports_read(&self) -> bool
fn supports_read(&self) -> bool
Whether this source supports reading/parsing PDFs
Sourcefn supports_citations(&self) -> bool
fn supports_citations(&self) -> bool
Whether this source supports citation/reference lookup
Sourcefn supports_doi_lookup(&self) -> bool
fn supports_doi_lookup(&self) -> bool
Whether this source supports lookup by DOI
Whether this source supports author search
Sourcefn search<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Search for papers matching the query
Search for papers by a specific author
Sourcefn download<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn download<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 DownloadRequest,
) -> Pin<Box<dyn Future<Output = Result<DownloadResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Download a paper’s PDF to the specified path
Sourcefn read<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ReadRequest,
) -> Pin<Box<dyn Future<Output = Result<ReadResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ReadRequest,
) -> Pin<Box<dyn Future<Output = Result<ReadResult, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read and extract text from a paper’s PDF
Sourcefn get_citations<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_citations<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get papers that cite this paper
Sourcefn get_references<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_references<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 CitationRequest,
) -> Pin<Box<dyn Future<Output = Result<SearchResponse, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get papers referenced by this paper
Get related papers
Sourcefn get_by_doi<'life0, 'life1, 'async_trait>(
&'life0 self,
_doi: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Paper, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_doi<'life0, 'life1, 'async_trait>(
&'life0 self,
_doi: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Paper, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a paper by its DOI
Sourcefn get_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Paper, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Paper, SourceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a paper by its ID (source-specific)
Sourcefn validate_id(&self, _id: &str) -> Result<(), SourceError>
fn validate_id(&self, _id: &str) -> Result<(), SourceError>
Validate that a paper ID is correctly formatted for this source