@@ -10,6 +10,58 @@ use tar::Archive;
10
10
11
11
static CRATES_ROOT : & str = "https://static.crates.io/crates" ;
12
12
13
+ pub struct AlternativeRegistry {
14
+ registry_index : String ,
15
+ }
16
+
17
+ impl AlternativeRegistry {
18
+ pub fn new ( registry_index : impl Into < String > ) -> AlternativeRegistry {
19
+ AlternativeRegistry {
20
+ registry_index : registry_index. into ( ) ,
21
+ }
22
+ }
23
+
24
+ fn index ( & self ) -> & str {
25
+ self . registry_index . as_str ( )
26
+ }
27
+
28
+ fn index_folder ( & self ) -> String {
29
+ crate :: utils:: escape_path ( self . registry_index . as_bytes ( ) )
30
+ }
31
+ }
32
+
33
+ pub enum Registry {
34
+ CratesIo ,
35
+ Alternative ( AlternativeRegistry ) ,
36
+ }
37
+
38
+ impl Registry {
39
+ fn cache_folder ( & self ) -> String {
40
+ match self {
41
+ Registry :: CratesIo => "cratesio-sources" . into ( ) ,
42
+ Registry :: Alternative ( alt) => format ! ( "{}-sources" , alt. index_folder( ) ) ,
43
+ }
44
+ }
45
+
46
+ fn name ( & self ) -> String {
47
+ match self {
48
+ Registry :: CratesIo => "crates.io" . into ( ) ,
49
+ Registry :: Alternative ( alt) => alt. index ( ) . to_string ( ) ,
50
+ }
51
+ }
52
+ }
53
+
54
+ pub ( super ) struct RegistryCrate {
55
+ registry : Registry ,
56
+ name : String ,
57
+ version : String ,
58
+ }
59
+
60
+ #[ derive( serde:: Deserialize ) ]
61
+ struct IndexConfig {
62
+ dl : String ,
63
+ }
64
+
13
65
impl RegistryCrate {
14
66
pub ( super ) fn new ( registry : Registry , name : & str , version : & str ) -> Self {
15
67
RegistryCrate {
@@ -69,58 +121,6 @@ impl RegistryCrate {
69
121
}
70
122
}
71
123
72
- #[ derive( serde:: Deserialize ) ]
73
- struct IndexConfig {
74
- dl : String ,
75
- }
76
-
77
- pub struct AlternativeRegistry {
78
- registry_index : String ,
79
- }
80
-
81
- impl AlternativeRegistry {
82
- pub fn new ( registry_index : impl Into < String > ) -> AlternativeRegistry {
83
- AlternativeRegistry {
84
- registry_index : registry_index. into ( ) ,
85
- }
86
- }
87
-
88
- fn index ( & self ) -> & str {
89
- self . registry_index . as_str ( )
90
- }
91
-
92
- fn index_folder ( & self ) -> String {
93
- crate :: utils:: escape_path ( self . registry_index . as_bytes ( ) )
94
- }
95
- }
96
-
97
- pub enum Registry {
98
- CratesIo ,
99
- Alternative ( AlternativeRegistry ) ,
100
- }
101
-
102
- impl Registry {
103
- fn cache_folder ( & self ) -> String {
104
- match self {
105
- Registry :: CratesIo => "cratesio-sources" . into ( ) ,
106
- Registry :: Alternative ( alt) => format ! ( "{}-sources" , alt. index( ) ) ,
107
- }
108
- }
109
-
110
- fn name ( & self ) -> String {
111
- match self {
112
- Registry :: CratesIo => "crates.io" . into ( ) ,
113
- Registry :: Alternative ( _alt) => todo ! ( ) ,
114
- }
115
- }
116
- }
117
-
118
- pub ( super ) struct RegistryCrate {
119
- registry : Registry ,
120
- name : String ,
121
- version : String ,
122
- }
123
-
124
124
impl CrateTrait for RegistryCrate {
125
125
fn fetch ( & self , workspace : & Workspace ) -> Result < ( ) , Error > {
126
126
let local = self . cache_path ( workspace) ;
0 commit comments