wx_rust_common/util/http/
media_download_request_executor.rs1use async_trait::async_trait;
7
8use crate::enums::WxType;
9use crate::error::WxErrorException;
10use crate::util::http::RequestExecutor;
11
12#[derive(Debug, Clone)]
16pub struct MediaDownloadRequestExecutor {
17 client: reqwest::Client,
19}
20
21impl MediaDownloadRequestExecutor {
22 pub fn new(client: reqwest::Client) -> Self {
24 Self { client }
25 }
26}
27
28#[async_trait]
29impl RequestExecutor<Vec<u8>, String> for MediaDownloadRequestExecutor {
30 async fn execute(
31 &self,
32 uri: &str,
33 _data: String,
34 _wx_type: WxType,
35 ) -> Result<Vec<u8>, WxErrorException> {
36 let resp = self.client.get(uri).send().await?;
37 let bytes = resp.bytes().await?.to_vec();
38 Ok(bytes)
39 }
40}