MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / deserialize

Method deserialize

src/project_config/interfaces.rs:81–107  ·  view source on GitHub ↗
(deserializer: D)

Source from the content-addressed store, hash-verified

79// directly supported by serde's untagged enums.
80impl<'de> Deserialize<'de> for TargetCommand {
81 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
82 where
83 D: Deserializer<'de>,
84 {
85 #[derive(Deserialize)]
86 #[serde(rename_all = "kebab-case")]
87 struct RawTarget {
88 exec: Option<String>,
89 entrypoint: Option<String>,
90 }
91
92 let raw = RawTarget::deserialize(deserializer)?;
93 Ok(match (raw.exec, raw.entrypoint) {
94 (Some(exec), None) => TargetCommand::Exec { exec },
95 (None, Some(entrypoint)) => TargetCommand::Entrypoint { entrypoint },
96 (Some(_), Some(_)) => {
97 return Err(serde::de::Error::custom(
98 "a target cannot have both `exec` and `entrypoint`",
99 ));
100 }
101 (None, None) => {
102 return Err(serde::de::Error::custom(
103 "a target must have either `exec` or `entrypoint`",
104 ));
105 }
106 })
107 }
108}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected