@@ -11,13 +11,14 @@ use crate::{
11
11
libraries:: { LibrariesDownloader , LibrariesMapper } ,
12
12
} ,
13
13
progress:: ProgressSender ,
14
- traits:: { DownloadResult , Downloader , DownloaderIO , DownloaderIOExt } ,
14
+ traits:: { DownloadResult , Downloader } ,
15
15
DownloadQueue ,
16
16
} ,
17
17
fs:: write_to_file,
18
18
game_paths:: GamePaths ,
19
19
repository:: manifest:: { Classifiers , DownloadFile , Library , Manifest } ,
20
20
state:: get_launcher_manifest,
21
+ PinnedFutureWithBounds ,
21
22
} ;
22
23
23
24
#[ derive( Debug ) ]
@@ -108,23 +109,6 @@ impl LibrariesMapper<Library> for VanillaNativeLibrariesMapper<'_> {
108
109
}
109
110
}
110
111
111
- #[ allow( clippy:: module_name_repetitions) ]
112
- pub struct VanillaIO < ' a > {
113
- manifest : & ' a Manifest ,
114
- version_path : & ' a Path ,
115
- }
116
-
117
- #[ async_trait:: async_trait]
118
- impl DownloaderIO for VanillaIO < ' _ > {
119
- async fn io ( & self ) -> anyhow:: Result < ( ) > {
120
- let path = self . version_path . join ( format ! ( "{}.json" , self . manifest. id) ) ;
121
-
122
- let body = serde_json:: to_string_pretty ( & self . manifest ) ?;
123
-
124
- write_to_file ( body. as_bytes ( ) , & path) . await
125
- }
126
- }
127
-
128
112
#[ async_trait:: async_trait]
129
113
impl Downloader for Vanilla {
130
114
type Data = DownloadResult ;
@@ -136,15 +120,20 @@ impl Downloader for Vanilla {
136
120
async fn download ( self : Box < Self > , sender : & dyn ProgressSender < Self :: Data > ) {
137
121
Box :: new ( self . queue ) . download ( sender) . await ;
138
122
}
139
- }
140
123
141
- impl < ' a > DownloaderIOExt < ' a > for Vanilla {
142
- type IO = VanillaIO < ' a > ;
124
+ fn io ( & self ) -> PinnedFutureWithBounds < anyhow:: Result < ( ) > > {
125
+ let versions_path = self . game_paths . version . clone ( ) ;
126
+ let manifest_id = self . manifest . id . clone ( ) ;
127
+ let manifest_res = serde_json:: to_string_pretty ( & self . manifest ) ;
143
128
144
- fn get_io ( & ' a self ) -> VanillaIO < ' a > {
145
- VanillaIO {
146
- manifest : & self . manifest ,
147
- version_path : & self . game_paths . version ,
148
- }
129
+ let fut = async move {
130
+ let path = versions_path. join ( format ! ( "{manifest_id}.json" ) ) ;
131
+
132
+ let body = manifest_res?;
133
+
134
+ write_to_file ( body. as_bytes ( ) , & path) . await
135
+ } ;
136
+
137
+ Box :: pin ( fut)
149
138
}
150
139
}
0 commit comments