Commit 324ca1a 1 parent cbbcf29 commit 324ca1a Copy full SHA for 324ca1a
File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use crate::{
8
8
use futures_util:: {
9
9
io:: { AsyncRead , Result as FuturesResult } ,
10
10
task:: { Context , Poll } ,
11
+ Stream ,
11
12
} ;
12
13
#[ cfg( feature = "async-multipart" ) ]
13
14
use pin_utils:: unsafe_pinned;
@@ -293,6 +294,29 @@ impl<B: AsyncRead + Unpin> AsyncRead for Multipart<B> {
293
294
}
294
295
}
295
296
297
+ #[ cfg( feature = "async-multipart" ) ]
298
+ impl Stream for Multipart < bytes:: Bytes > {
299
+ type Item = bytes:: Bytes ;
300
+
301
+ fn poll_next ( mut self : Pin < & mut Self > , _cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
302
+ Poll :: Ready ( match self . cursor . part {
303
+ MultipartPart :: Prefix => {
304
+ self . cursor . part . next ( ) ;
305
+ Some ( self . prefix . clone ( ) )
306
+ }
307
+ MultipartPart :: Body => {
308
+ self . cursor . part . next ( ) ;
309
+ Some ( self . body . clone ( ) )
310
+ }
311
+ MultipartPart :: Suffix => {
312
+ self . cursor . part . next ( ) ;
313
+ Some ( bytes:: Bytes :: from ( MULTI_PART_SUFFIX ) )
314
+ }
315
+ MultipartPart :: End => None ,
316
+ } )
317
+ }
318
+ }
319
+
296
320
impl super :: Object {
297
321
/// Stores a new object and metadata.
298
322
///
You can’t perform that action at this time.
0 commit comments