spider_downloader/
traits.rs1use async_trait::async_trait;
4use bytes::Bytes;
5use http::StatusCode;
6use spider_util::error::SpiderError;
7use spider_util::request::Request;
8use spider_util::response::Response;
9use std::time::Duration;
10
11#[async_trait]
13pub trait SimpleHttpClient: Send + Sync {
14 async fn get_text(
16 &self,
17 url: &str,
18 timeout: Duration,
19 ) -> Result<(StatusCode, Bytes), SpiderError>;
20}
21
22#[async_trait]
24pub trait Downloader: Send + Sync + 'static {
25 type Client: Send + Sync;
26
27 async fn download(&self, request: Request) -> Result<Response, SpiderError>;
30
31 fn client(&self) -> &Self::Client;
33}