From 1c60d426c985ec287dc3a80198cca3bc83f6f26a Mon Sep 17 00:00:00 2001 From: redxef Date: Wed, 30 Oct 2024 01:22:40 +0100 Subject: [PATCH] fix: make optional inputs actually optional. --- src/main.rs | 14 ++++++++------ src/model.rs | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 82c58c2..52f7348 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,11 +170,13 @@ async fn in_(input: model::InInput, dest: &Path) -> Result { }, metadata: vec![], }; - if out.version != input.version { - return Err(anyhow!(format!( - "Did not get correct version of resource, requested '{:?}', got '{:?}'", - input.version, out.version - ))); + if let Some(input_version) = &input.version { + if out.version != *input_version { + return Err(anyhow!(format!( + "Did not get correct version of resource, requested '{:?}', got '{:?}'", + input.version, out.version + ))); + } } Ok(out) } @@ -189,7 +191,7 @@ async fn out(input: model::OutInput, src: &Path) -> Result { response.error_for_status()?; let version = check(model::CheckInput { source: input.source.clone(), - version: model::Version::None, + version: None, }) .await? .0[0] diff --git a/src/model.rs b/src/model.rs index ceb0795..3bbde5e 100644 --- a/src/model.rs +++ b/src/model.rs @@ -150,19 +150,22 @@ pub struct Params { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct CheckInput { pub source: Source, - pub version: Version, + #[serde(default)] + pub version: Option, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct InInput { pub source: Source, - pub version: Version, + pub version: Option, + #[serde(default)] pub params: Params, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct OutInput { pub source: Source, + #[serde(default)] pub params: Params, }