#[cfg(feature = "http")]
pub mod http;
#[cfg(feature = "http")]
#[cfg_attr(not(feature = "robots"), allow(unused_imports))]
pub(crate) use http::DEFAULT_UA;
#[cfg(feature = "http")]
pub use http::HttpFetcher;
use crate::error::Result;
use crate::payload::DocPayload;
use crate::resource::Resource;
use crate::resource::ResourceKind;
use compact_str::CompactString;
use std::future::Future;
use url::Url;
#[derive(Clone, Debug)]
pub struct FetchMeta {
pub kind: ResourceKind,
pub etag: Option<CompactString>,
pub status: u16,
pub final_url: Option<Url>,
}
#[derive(Debug)]
pub struct Fetched<'a> {
pub meta: FetchMeta,
pub payload: DocPayload<'a>,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct FetchOptions<'a> {
pub if_none_match: Option<&'a str>,
pub max_bytes: Option<u64>,
pub user_agent: Option<&'a str>,
}
pub trait Fetcher: Send + Sync {
type FetchFuture<'a>: Future<Output = Result<Fetched<'a>>> + Send + 'a
where
Self: 'a;
fn fetch<'a>(&'a self, resource: &'a Resource, opts: FetchOptions<'a>)
-> Self::FetchFuture<'a>;
}