Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Make necessary traits _pub_ and add basic error handling #7

Merged
merged 2 commits into from Nov 26, 2020

Conversation

soenkeliebau
Copy link
Member

This PR makes the traits that are intended for external usage public, which was forgotten before.

Also, some functions are refactored to be able to return errors as part of a Result<..,..> type.

config/src/lib.rs Outdated Show resolved Hide resolved
config/src/lib.rs Outdated Show resolved Hide resolved
config/src/lib.rs Outdated Show resolved Hide resolved
@@ -568,7 +574,7 @@ mod tests {
OsString::from("--testmultiple"),
OsString::from("3"),
];
let config: TestConfig = ConfigBuilder::build(command_line_args, &env_var_name)
let config: TestConfig = *ConfigBuilder::build(command_line_args, &env_var_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these derefs can go if you make config type Box, it'll be dereferenced automatically later so it should compile.

That said: See commment about Box earlier.

fn parse_values(parsed_values: HashMap<ConfigOption, Option<Vec<String>>>) -> Self;
fn parse_values(
parsed_values: HashMap<ConfigOption, Option<Vec<String>>>,
) -> Result<Box<Self>, anyhow::Error>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need any of these Box things as long as Configurable is Sized. I'm not 100% sure but removing all of those and running the tests works.

I also think that anyhow shouldn't appear in the API (but I'm not sure about that tbh.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think trying to return the trait Error from these functions in the result was what got me started down the Box<..> route, so using anyhow::error removed the need for Boxes all over the place. I agree that it would be nicer to define a proper error type and have those error be part of the api though.

@lfrancke lfrancke added this to In progress in Stackable Nov 26, 2020
Stackable automation moved this from In progress to To be merged Nov 26, 2020
@lfrancke lfrancke merged commit 5285f84 into stackabletech:main Nov 26, 2020
Stackable automation moved this from To be merged to Done Nov 26, 2020
@soenkeliebau soenkeliebau deleted the generic_of_main branch November 26, 2020 16:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants