File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,24 @@ pub struct DownloadHandle {
34
34
cancel : oneshot:: Sender < ( ) > ,
35
35
}
36
36
37
- impl DownloadHandle {
38
- pub async fn r#await ( self ) -> Result < File , Error > {
39
- match self . result . await {
40
- Ok ( result) => result,
41
- Err ( _) => todo ! ( ) ,
37
+ impl std:: future:: Future for DownloadHandle {
38
+ type Output = Result < tokio:: fs:: File , Error > ;
39
+
40
+ fn poll (
41
+ mut self : std:: pin:: Pin < & mut Self > ,
42
+ cx : & mut std:: task:: Context < ' _ > ,
43
+ ) -> std:: task:: Poll < Self :: Output > {
44
+ use std:: pin:: Pin ;
45
+ use std:: task:: Poll ;
46
+ match Pin :: new ( & mut self . result ) . poll ( cx) {
47
+ Poll :: Ready ( Ok ( result) ) => Poll :: Ready ( result) ,
48
+ Poll :: Ready ( Err ( e) ) => Poll :: Ready ( Err ( Error :: Oneshot ( e) ) ) ,
49
+ Poll :: Pending => Poll :: Pending ,
42
50
}
43
51
}
52
+ }
44
53
54
+ impl DownloadHandle {
45
55
pub fn status ( & self ) -> Status {
46
56
self . status . borrow ( ) . clone ( )
47
57
}
Original file line number Diff line number Diff line change @@ -8,4 +8,6 @@ pub enum Error {
8
8
Serde ( #[ from] serde_json:: Error ) ,
9
9
#[ error( "Reqwest: {0}" ) ]
10
10
Reqwest ( #[ from] reqwest:: Error ) ,
11
+ #[ error( "Oneshot: {0}" ) ]
12
+ Oneshot ( #[ from] tokio:: sync:: oneshot:: error:: RecvError ) ,
11
13
}
You can’t perform that action at this time.
0 commit comments