@@ -6,11 +6,11 @@ use std::collections::BTreeMap;
66use std:: path:: Path ;
77use thiserror:: Error ;
88
9- pub const PROFILE_CONFIG_SCHEMA_VERSION : u32 = 1 ;
9+ pub const PACKAGE_CONFIG_SCHEMA_VERSION : u32 = 1 ;
1010
1111#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
1212#[ serde( deny_unknown_fields) ]
13- pub struct ProfileConfigLayer {
13+ pub struct PackageConfigLayer {
1414 pub schema_version : u32 ,
1515 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1616 pub package : Option < PackagePatch > ,
@@ -72,26 +72,26 @@ pub struct ProfilePatch {
7272 pub verification_commands : Option < Vec < VerificationCommand > > ,
7373}
7474
75- impl ProfileConfigLayer {
76- pub fn from_toml_str ( input : & str ) -> Result < Self , ProfileConfigError > {
75+ impl PackageConfigLayer {
76+ pub fn from_toml_str ( input : & str ) -> Result < Self , PackageConfigError > {
7777 let layer: Self = toml:: from_str ( input) ?;
7878 layer. validate ( ) ?;
7979 Ok ( layer)
8080 }
8181
82- pub fn from_path ( path : & Path ) -> Result < Self , ProfileConfigError > {
82+ pub fn from_path ( path : & Path ) -> Result < Self , PackageConfigError > {
8383 let input = std:: fs:: read_to_string ( path)
84- . map_err ( |error| ProfileConfigError :: Io ( path. display ( ) . to_string ( ) , error) ) ?;
84+ . map_err ( |error| PackageConfigError :: Io ( path. display ( ) . to_string ( ) , error) ) ?;
8585 Self :: from_toml_str ( & input)
8686 }
8787
88- fn validate ( & self ) -> Result < ( ) , ProfileConfigError > {
89- if self . schema_version != PROFILE_CONFIG_SCHEMA_VERSION {
90- return Err ( ProfileConfigError :: UnsupportedSchema ( self . schema_version ) ) ;
88+ fn validate ( & self ) -> Result < ( ) , PackageConfigError > {
89+ if self . schema_version != PACKAGE_CONFIG_SCHEMA_VERSION {
90+ return Err ( PackageConfigError :: UnsupportedSchema ( self . schema_version ) ) ;
9191 }
9292 for profile in & self . profiles {
9393 if profile. name . trim ( ) . is_empty ( ) {
94- return Err ( ProfileConfigError :: EmptyProfileName ) ;
94+ return Err ( PackageConfigError :: EmptyProfileName ) ;
9595 }
9696 }
9797 if self
@@ -100,40 +100,40 @@ impl ProfileConfigLayer {
100100 . and_then ( |package| package. name . as_deref ( ) )
101101 . is_some_and ( |name| name. trim ( ) . is_empty ( ) )
102102 {
103- return Err ( ProfileConfigError :: EmptyPackageName ) ;
103+ return Err ( PackageConfigError :: EmptyPackageName ) ;
104104 }
105105 if self
106106 . package
107107 . as_ref ( )
108108 . and_then ( |package| package. version . as_deref ( ) )
109109 . is_some_and ( |version| version. trim ( ) . is_empty ( ) )
110110 {
111- return Err ( ProfileConfigError :: EmptyPackageVersion ) ;
111+ return Err ( PackageConfigError :: EmptyPackageVersion ) ;
112112 }
113113 if self
114114 . build
115115 . as_ref ( )
116116 . and_then ( |build| build. easyblock . as_deref ( ) )
117117 . is_some_and ( |easyblock| easyblock. trim ( ) . is_empty ( ) )
118118 {
119- return Err ( ProfileConfigError :: EmptyEasyblock ) ;
119+ return Err ( PackageConfigError :: EmptyEasyblock ) ;
120120 }
121121 if self
122122 . build
123123 . as_ref ( )
124124 . and_then ( |build| build. moduleclass . as_deref ( ) )
125125 . is_some_and ( |moduleclass| moduleclass. trim ( ) . is_empty ( ) )
126126 {
127- return Err ( ProfileConfigError :: EmptyModuleclass ) ;
127+ return Err ( PackageConfigError :: EmptyModuleclass ) ;
128128 }
129129 Ok ( ( ) )
130130 }
131131}
132132
133- pub fn apply_profile_layers (
133+ pub fn apply_package_layers (
134134 plan : & mut PackagePlan ,
135- layers : & [ ProfileConfigLayer ] ,
136- ) -> Result < ( ) , ProfileConfigError > {
135+ layers : & [ PackageConfigLayer ] ,
136+ ) -> Result < ( ) , PackageConfigError > {
137137 for layer in layers {
138138 layer. validate ( ) ?;
139139 if let Some ( package) = & layer. package {
@@ -183,7 +183,7 @@ pub fn apply_profile_layers(
183183 . iter ( )
184184 . find ( |profile| profile. name == parent)
185185 . cloned ( )
186- . ok_or_else ( || ProfileConfigError :: MissingParent {
186+ . ok_or_else ( || PackageConfigError :: MissingParent {
187187 profile : patch. name . clone ( ) ,
188188 parent : parent. to_string ( ) ,
189189 } ) ?;
@@ -234,7 +234,7 @@ pub fn apply_profile_layers(
234234 . filter ( |profile| profile. default )
235235 . count ( ) ;
236236 if default_count != 1 {
237- return Err ( ProfileConfigError :: DefaultProfileCount ( default_count) ) ;
237+ return Err ( PackageConfigError :: DefaultProfileCount ( default_count) ) ;
238238 }
239239 let stack = plan. build . toolchain . label ( ) ;
240240 plan. outputs = plan
@@ -249,12 +249,12 @@ pub fn apply_profile_layers(
249249}
250250
251251#[ derive( Debug , Error ) ]
252- pub enum ProfileConfigError {
253- #[ error( "unsupported profile config schema version {0}" ) ]
252+ pub enum PackageConfigError {
253+ #[ error( "unsupported package config schema version {0}" ) ]
254254 UnsupportedSchema ( u32 ) ,
255- #[ error( "profile config TOML: {0}" ) ]
255+ #[ error( "package config TOML: {0}" ) ]
256256 Toml ( #[ from] toml:: de:: Error ) ,
257- #[ error( "read profile config {0}: {1}" ) ]
257+ #[ error( "read package config {0}: {1}" ) ]
258258 Io ( String , std:: io:: Error ) ,
259259 #[ error( "profile name cannot be empty" ) ]
260260 EmptyProfileName ,
0 commit comments