pub trait Fetcher: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn matches(&self, url: &Url) -> bool;
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 FetchRequest,
options: &'life2 FetchOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchResponse, FetchError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided method
fn fetch_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request: &'life1 FetchRequest,
options: &'life2 FetchOptions,
saver: &'life3 dyn FileSaver,
) -> Pin<Box<dyn Future<Output = Result<FetchResponse, FetchError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Trait for specialized content fetchers
Implement this trait to create custom fetchers for specific URL patterns.
Each fetcher declares what URLs it can handle via matches() and
performs the actual fetch via fetch().
Required Methods§
Sourcefn matches(&self, url: &Url) -> bool
fn matches(&self, url: &Url) -> bool
Returns true if this fetcher can handle the given URL
Called by the registry to determine which fetcher to use. More specific fetchers should be registered before generic ones.
Sourcefn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 FetchRequest,
options: &'life2 FetchOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchResponse, FetchError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 FetchRequest,
options: &'life2 FetchOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchResponse, FetchError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetch content from the URL
Called only if matches() returned true.
Returns a FetchResponse on success or FetchError on failure.
Provided Methods§
Sourcefn fetch_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request: &'life1 FetchRequest,
options: &'life2 FetchOptions,
saver: &'life3 dyn FileSaver,
) -> Pin<Box<dyn Future<Output = Result<FetchResponse, FetchError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn fetch_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
request: &'life1 FetchRequest,
options: &'life2 FetchOptions,
saver: &'life3 dyn FileSaver,
) -> Pin<Box<dyn Future<Output = Result<FetchResponse, FetchError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Fetch with file saving support.
Default implementation delegates to fetch(), then saves content through the saver.
Specialized fetchers (e.g. DefaultFetcher) override this for binary-aware saving.