From 402f8c144c2114d6c38a0b7dfa786420688996af Mon Sep 17 00:00:00 2001 From: Joni Kemppainen <102905925+Kemppis3@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:40:29 +0300 Subject: [PATCH] Add parser --- src/config.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/config.rs b/src/config.rs index 8aba233..010a7bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -148,3 +148,17 @@ impl WeeksTasksOutput { WeeksTasksOutput { name, output_type } } } + +pub fn read_toml_content_from_file(filepath: &str) -> Result> { + let mut file = fs::File::open(filepath)?; + let mut file_content = String::new(); + file.read_to_string(&mut file_content)?; + Ok(file_content) +} + + +//TODO: Add warnings for unspecified fields +pub fn toml_content(file_content: String) -> Result> { + let course_config: CourseConfiguration = toml::from_str(&file_content)?; + Ok(course_config) +}