use instructions::Instruction; use serde::{Deserialize, Serialize}; pub mod instructions; /// # Panics /// /// Panics if deserialization fails. lol. #[must_use] pub fn from_ron(raw: &str) -> Rpl { ron::from_str(raw).expect("come back later and handle me correctly") } #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] pub struct Rpl(pub Vec); #[cfg(test)] mod tests { use super::*; use crate::instructions::{ read::{SourceFormat, SourceType}, write::{TargetFormat, TargetType}, MathInstruction, }; #[test] fn test_simple_deserialize() { const TEST_DATA: &str = "([Read( (source: File(\"~/example/file.png\"), format: Png) ),Math(Add),Write(( target: File(\"~/example/out.jpg\"), format: Jpeg))])"; assert_eq!( from_ron(TEST_DATA), Rpl(vec![ Instruction::Read(instructions::read::Read { source: SourceType::File("~/example/file.png".into()), format: SourceFormat::Png }), Instruction::Math(MathInstruction::Add), Instruction::Write(instructions::write::Write { target: TargetType::File("~/example/out.jpg".into()), format: TargetFormat::Jpeg }) ]) ); } }