@@ -4,7 +4,8 @@ use std::{pin::Pin, task::Poll};
44
55use async_trait:: async_trait;
66use digest:: { Digest , Output } ;
7- use futures:: { io:: BufWriter , AsyncWrite , AsyncWriteExt } ;
7+ use futures:: { io:: BufWriter , AsyncWrite } ;
8+ use futures_util:: AsyncWriteExt ;
89use pin_project_lite:: pin_project;
910
1011pin_project ! {
@@ -25,7 +26,7 @@ pub trait Checksum<D: Digest> {
2526 async fn finalize ( & mut self ) -> std:: io:: Result < Option < Output < D > > > ;
2627}
2728
28- impl < D : Digest , W : AsyncWrite + Unpin > AsyncWrite for AsyncWriterWithChecksum < D , W > {
29+ impl < D : Digest , W : AsyncWriteExt + Unpin > AsyncWrite for AsyncWriterWithChecksum < D , W > {
2930 fn poll_write (
3031 mut self : std:: pin:: Pin < & mut Self > ,
3132 cx : & mut std:: task:: Context < ' _ > ,
@@ -59,9 +60,10 @@ impl<D: Digest, W: AsyncWrite + Unpin> AsyncWrite for AsyncWriterWithChecksum<D,
5960}
6061
6162#[ async_trait]
62- impl < D : Digest + Send , W : AsyncWrite + Send + Unpin > Checksum < D > for AsyncWriterWithChecksum < D , W > {
63+ impl < D : Digest + Send , W : AsyncWriteExt + Send + Unpin > Checksum < D >
64+ for AsyncWriterWithChecksum < D , W >
65+ {
6366 async fn finalize ( & mut self ) -> std:: io:: Result < Option < Output < D > > > {
64- self . inner . flush ( ) . await ?;
6567 if let Some ( hasher) = & mut self . hasher {
6668 let hasher = std:: mem:: replace ( hasher, D :: new ( ) ) ;
6769 Ok ( Some ( hasher. finalize ( ) ) )
@@ -133,6 +135,9 @@ mod test {
133135 temp_file_writer. write_all ( & bytes) . await ?;
134136 }
135137
138+ temp_file_writer. flush ( ) . await ?;
139+ temp_file_writer. close ( ) . await ?;
140+
136141 let checksum = temp_file_writer. finalize ( ) . await ?;
137142
138143 let file_hash = {
0 commit comments