@@ -267,32 +267,35 @@ impl<A: Access> LayeredAccess for BlockingAccessor<A> {
267
267
268
268
pub struct BlockingWrapper < I > {
269
269
handle : Handle ,
270
- inner : I ,
270
+ inner : Option < I > ,
271
271
}
272
272
273
273
impl < I > BlockingWrapper < I > {
274
274
fn new ( handle : Handle , inner : I ) -> Self {
275
- Self { handle, inner }
275
+ Self {
276
+ handle,
277
+ inner : Some ( inner) ,
278
+ }
276
279
}
277
280
}
278
281
279
282
impl < I : oio:: Read + ' static > oio:: BlockingRead for BlockingWrapper < I > {
280
283
fn read ( & mut self ) -> Result < Buffer > {
281
- self . handle . block_on ( self . inner . read ( ) )
284
+ self . handle . block_on ( self . inner . as_mut ( ) . unwrap ( ) . read ( ) )
282
285
}
283
286
}
284
287
285
288
impl < I : oio:: Write + ' static > oio:: BlockingWrite for BlockingWrapper < I > {
286
289
fn write ( & mut self , bs : Buffer ) -> Result < ( ) > {
287
- self . handle . block_on ( self . inner . write ( bs) )
290
+ self . handle . block_on ( self . inner . as_mut ( ) . unwrap ( ) . write ( bs) )
288
291
}
289
292
290
293
fn close ( & mut self ) -> Result < Metadata > {
291
- self . handle . block_on ( self . inner . close ( ) )
294
+ self . handle . block_on ( self . inner . as_mut ( ) . unwrap ( ) . close ( ) )
292
295
}
293
296
}
294
297
295
- impl < I > Drop for BlockingWrapper < I > {
298
+ impl < I : Send + ' static > Drop for BlockingWrapper < I > {
296
299
fn drop ( & mut self ) {
297
300
if let Some ( inner) = self . inner . take ( ) {
298
301
self . handle . spawn ( async move {
@@ -304,17 +307,17 @@ impl<I> Drop for BlockingWrapper<I> {
304
307
305
308
impl < I : oio:: List > oio:: BlockingList for BlockingWrapper < I > {
306
309
fn next ( & mut self ) -> Result < Option < oio:: Entry > > {
307
- self . handle . block_on ( self . inner . next ( ) )
310
+ self . handle . block_on ( self . inner . as_mut ( ) . unwrap ( ) . next ( ) )
308
311
}
309
312
}
310
313
311
314
impl < I : oio:: Delete + ' static > oio:: BlockingDelete for BlockingWrapper < I > {
312
315
fn delete ( & mut self , path : & str , args : OpDelete ) -> Result < ( ) > {
313
- self . inner . delete ( path, args)
316
+ self . inner . as_mut ( ) . unwrap ( ) . delete ( path, args)
314
317
}
315
318
316
319
fn flush ( & mut self ) -> Result < usize > {
317
- self . handle . block_on ( self . inner . flush ( ) )
320
+ self . handle . block_on ( self . inner . as_mut ( ) . unwrap ( ) . flush ( ) )
318
321
}
319
322
}
320
323
0 commit comments