Signed-off-by: junxiang Mu <1948535941@qq.com>
This commit is contained in:
junxiang Mu
2025-04-28 21:55:31 +08:00
parent c1590a054c
commit 66f5bf1bbc
3 changed files with 27 additions and 23 deletions
+8 -4
View File
@@ -1,3 +1,4 @@
use async_trait::async_trait;
use bytes::Bytes;
use futures::TryStreamExt;
use md5::Digest;
@@ -128,8 +129,9 @@ impl AsyncRead for HttpFileReader {
}
}
pub trait {
#[async_trait]
pub trait Etag {
async fn etag(self) -> String;
}
pin_project! {
@@ -140,7 +142,6 @@ pin_project! {
}
}
impl<R> EtagReader<R> {
pub fn new(inner: R) -> Self {
let (bytes_tx, mut bytes_rx) = mpsc::channel::<Bytes>(8);
@@ -158,8 +159,11 @@ impl<R> EtagReader<R> {
EtagReader { inner, bytes_tx, md5_rx }
}
}
pub async fn etag(self) -> String {
#[async_trait]
impl<R: Send> Etag for EtagReader<R> {
async fn etag(self) -> String {
drop(self.inner);
drop(self.bytes_tx);
self.md5_rx.await.unwrap()