Skip to main content

Source

Trait Source 

Source
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:

  1. Create a new struct that implements Source
  2. Implement the required methods (at minimum id, name, and search)
  3. Implement optional methods if the source supports them
  4. Add the source to SourceRegistry::new() or register it dynamically

Required Methods§

Source

fn id(&self) -> &str

Unique identifier for this source (used in tool names, e.g., “arxiv”, “pubmed”)

Source

fn name(&self) -> &str

Human-readable name of this source

Provided Methods§

Source

fn capabilities(&self) -> SourceCapabilities

Describe the capabilities of this source

Whether this source supports search

Source

fn supports_download(&self) -> bool

Whether this source supports downloading PDFs

Source

fn supports_read(&self) -> bool

Whether this source supports reading/parsing PDFs

Source

fn supports_citations(&self) -> bool

Whether this source supports citation/reference lookup

Source

fn supports_doi_lookup(&self) -> bool

Whether this source supports lookup by DOI

Whether this source supports author search

Source

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

Source

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,

Search for papers by a specific author

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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)

Source

fn validate_id(&self, _id: &str) -> Result<(), SourceError>

Validate that a paper ID is correctly formatted for this source

Implementors§