WIP: impl profile evaluation #7

Draft
jturnerusa wants to merge 10 commits from feature/profiles into master
Showing only changes of commit 7e61192fba - Show all commits

View File

@@ -64,7 +64,7 @@ pub enum Error {
pub struct Profile {
#[get(kind = "deref")]
path: PathBuf,
eapi: Option<Eapi>,
eapi: Eapi,
deprecated: Option<String>,
#[get(kind = "deref")]
parents: Vec<Profile>,
@@ -108,9 +108,9 @@ impl Profile {
let eapi = match fs::read_to_string(&eapi_path)
.map(|s| Eapi::parse(s.trim()).map_err(str::to_string))
{
Ok(Ok(eapi)) => Some(eapi),
Ok(Ok(eapi)) => eapi,
Ok(Err(rest)) => return Err(Error::Parser(rest)),
jturnerusa marked this conversation as resolved Outdated

I think the default behavior for no eapi file per the spec is to treat it as eapi 0. Do we do that here, or are we erroring out if there's no eapi file?

Maybe it should assign eapi 0 on failure to parse (no eapi file), then later during evaluation of the parsed profile you throw an error saying you don't support eapi 0. That way eapi 0 (or other versions) could be supported later without having to change parsing logic.

I think the default behavior for no eapi file per the spec is to treat it as eapi 0. Do we do that here, or are we erroring out if there's no eapi file? Maybe it should assign eapi 0 on failure to parse (no eapi file), then later during evaluation of the parsed profile you throw an error saying you don't support eapi 0. That way eapi 0 (or other versions) could be supported later without having to change parsing logic.
Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => None,
Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => Eapi::parse("0").unwrap(),
Err(e) => return Err(Error::Io(eapi_path, e)),
};