We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
we'll use this logic https://rust-unofficial.github.io/patterns/patterns/creational/builder.html
Maybe we finally use only in-line format or one format and stick with it
The text was updated successfully, but these errors were encountered:
@Esgr0bar I don't think there's any need to handle XML/JSON/YAML. I think it's better if we stick to one specific format.
Sorry, something went wrong.
@shard77 no problem that doesn't change a lot the code we can stick to one format. Here's the code that handle the different format :
fn load_config(file_path: &str) -> Result<MachineConfig, Box<dyn Error>> { let config_str = fs::read_to_string(file_path)?; let config: MachineConfig = match file_path.rsplit('.').next().ok_or("No file extension found")? { "json" => serde_json::from_str(&config_str)?, "yaml" => serde_yaml::from_str(&config_str)?, "toml" => toml::from_str(&config_str)?, "xml" => serde_xml_rs::from_str(&config_str)?, _ => return Err("Unsupported file format".into()), }; Ok(config) }
@shard77 no problem that doesn't change a lot the code we can stick to one format. Here's the code that handle the different format : fn load_config(file_path: &str) -> Result<MachineConfig, Box<dyn Error>> { let config_str = fs::read_to_string(file_path)?; let config: MachineConfig = match file_path.rsplit('.').next().ok_or("No file extension found")? { "json" => serde_json::from_str(&config_str)?, "yaml" => serde_yaml::from_str(&config_str)?, "toml" => toml::from_str(&config_str)?, "xml" => serde_xml_rs::from_str(&config_str)?, _ => return Err("Unsupported file format".into()), }; Ok(config) }
alright, perfect 👍 @Esgr0bar Did you use the derive feature from serde?
@shard77 Yeah, you can look my code it is push in the branch
Esgr0bar
No branches or pull requests
we'll use this logic https://rust-unofficial.github.io/patterns/patterns/creational/builder.html
Maybe we finally use only in-line format or one format and stick with it
The text was updated successfully, but these errors were encountered: