1use async_trait::async_trait;
2use bytes::Bytes;
3use http::StatusCode;
4use std::time::Duration;
5
6use crate::error::SpiderError;
7use crate::request::Request;
8use crate::response::Response;
9
10#[async_trait]
12pub trait SimpleHttpClient: Send + Sync {
13 async fn get_text(
15 &self,
16 url: &str,
17 timeout: Duration,
18 ) -> Result<(StatusCode, Bytes), SpiderError>;
19}
20
21#[async_trait]
23pub trait Downloader: Send + Sync + 'static {
24 type Client: Send + Sync;
25 async fn download(&self, request: Request) -> Result<Response, SpiderError>;
28 fn client(&self) -> &Self::Client;
30}
31
32