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

Function pid_keys_from_strings

crates/runner-shared/src/metadata.rs:24–38  ·  view source on GitHub ↗

Reads a pid-keyed map whose keys arrive as strings. JSON object keys are always strings. serde_json's direct deserializer special-cases that and parses integer map keys, but a `#[serde(flatten)]` field is buffered into serde's internal `Content` first, and that path has no such special case — a `pid_t` key then fails with `invalid type: string`. See

(deserializer: D)

Source from the content-addressed store, hash-verified

22///
23/// Only the read side needs this: serializing writes the same bytes either way.
24fn pid_keys_from_strings<'de, V, D>(deserializer: D) -> Result<HashMap<pid_t, V>, D::Error>
25where
26 V: Deserialize<'de>,
27 D: Deserializer<'de>,
28{
29 HashMap::<String, V>::deserialize(deserializer)?
30 .into_iter()
31 .map(|(key, value)| {
32 let pid = key
33 .parse::<pid_t>()
34 .map_err(|_| D::Error::custom(format!("invalid pid key: {key}")))?;
35 Ok((pid, value))
36 })
37 .collect()
38}
39
40/// The per-profile module artifacts: the deduplicated debug info, unwind data
41/// and symbol tables extracted from the ELF modules the profiled processes

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected