@@ -17,13 +17,15 @@ use crate::{Result, State};
1717
1818mod curseforge;
1919mod modrinth;
20+ mod skyclient;
2021
2122/// Providers for content packages
2223#[ cfg_attr( feature = "specta" , derive( specta:: Type ) ) ]
2324#[ derive( Debug , PartialEq , Eq , Serialize , Deserialize , Clone ) ]
2425pub enum Providers {
2526 Modrinth ,
2627 Curseforge ,
28+ SkyClient ,
2729}
2830
2931impl std:: fmt:: Display for Providers {
@@ -39,6 +41,7 @@ impl Providers {
3941 match self {
4042 Self :: Modrinth => "Modrinth" ,
4143 Self :: Curseforge => "Curseforge" ,
44+ Self :: SkyClient => "SkyClient" ,
4245 }
4346 }
4447
@@ -48,11 +51,12 @@ impl Providers {
4851 match self {
4952 Self :: Modrinth => "https://modrinth.com" ,
5053 Self :: Curseforge => "https://curseforge.com" ,
54+ Self :: SkyClient => "https://skyclient.co" ,
5155 }
5256 }
5357
5458 pub const fn get_providers ( ) -> & ' static [ Providers ] {
55- & [ Self :: Modrinth , Self :: Curseforge ]
59+ & [ Self :: Modrinth , Self :: Curseforge , Self :: SkyClient ]
5660 }
5761
5862 #[ allow( clippy:: too_many_arguments) ]
@@ -98,35 +102,37 @@ impl Providers {
98102 )
99103 . await
100104 }
105+ Self :: SkyClient => {
106+ skyclient:: search (
107+ query,
108+ limit,
109+ offset,
110+ game_versions,
111+ loaders
112+ ) . await
113+ } ,
101114 }
102115 }
103116
104117 pub async fn get ( & self , slug_or_id : & str ) -> Result < ManagedPackage > {
105118 Ok ( match self {
106119 Self :: Modrinth => modrinth:: get ( slug_or_id) . await ?. into ( ) ,
107- Self :: Curseforge => curseforge:: get (
108- slug_or_id
109- . parse :: < u32 > ( )
110- . map_err ( |err| anyhow:: anyhow!( err) ) ?,
111- )
112- . await ?
113- . into ( ) ,
120+ Self :: Curseforge => curseforge:: get ( slug_or_id. parse :: < u32 > ( ) . map_err ( |err| anyhow:: anyhow!( err) ) ?) . await ?. into ( ) ,
121+ Self :: SkyClient => skyclient:: get ( slug_or_id) . await ?. into ( ) ,
114122 } )
115123 }
116124
117125 pub async fn get_multiple ( & self , slug_or_ids : & [ String ] ) -> Result < Vec < ManagedPackage > > {
118- Ok ( match self {
119- Self :: Modrinth => {
120- if slug_or_ids. len ( ) <= 0 {
121- return Ok ( vec ! [ ] ) ;
122- }
126+ if slug_or_ids. len ( ) <= 0 {
127+ return Ok ( vec ! [ ] ) ;
128+ }
123129
124- modrinth:: get_multiple ( slug_or_ids)
130+ Ok ( match self {
131+ Self :: Modrinth => modrinth:: get_multiple ( slug_or_ids)
125132 . await ?
126133 . into_iter ( )
127134 . map ( Into :: into)
128- . collect ( )
129- } ,
135+ . collect ( ) ,
130136 Self :: Curseforge => {
131137 let parsed_ids = slug_or_ids
132138 . iter ( )
@@ -145,6 +151,11 @@ impl Providers {
145151 . map ( Into :: into)
146152 . collect ( )
147153 } ,
154+ Self :: SkyClient => skyclient:: get_multiple ( slug_or_ids)
155+ . await ?
156+ . into_iter ( )
157+ . map ( Into :: into)
158+ . collect ( ) ,
148159 } )
149160 }
150161
@@ -166,6 +177,8 @@ impl Providers {
166177 let data = curseforge:: get_all_versions ( project_id, game_versions, loaders, page, page_size) . await ?;
167178 ( data. 0 . into_iter ( ) . map ( Into :: into) . collect ( ) , data. 1 )
168179 }
180+
181+ Self :: SkyClient => todo ! ( ) ,
169182 } )
170183 }
171184
@@ -181,6 +194,7 @@ impl Providers {
181194 . into_iter ( )
182195 . map ( Into :: into)
183196 . collect ( ) ,
197+ Self :: SkyClient => todo ! ( ) ,
184198 } )
185199 }
186200
@@ -215,7 +229,8 @@ impl Providers {
215229 . await ?
216230 . into_iter ( )
217231 . map ( |( hash, version) | ( hash, version. into ( ) ) )
218- . collect ( )
232+ . collect ( ) ,
233+ Self :: SkyClient => todo ! ( ) ,
219234 } )
220235 }
221236}
0 commit comments