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

Function load

src/shell_session_store.rs:86–101  ·  view source on GitHub ↗

Look up a previously-registered value by walking up the process tree from this process. Returns `None` if no ancestor has registered a value.

(kind: SessionKind)

Source from the content-addressed store, hash-verified

84/// Look up a previously-registered value by walking up the process tree from
85/// this process. Returns `None` if no ancestor has registered a value.
86pub(crate) fn load<T: DeserializeOwned>(kind: SessionKind) -> Result<Option<T>> {
87 let dir = get_root_dir(kind);
88 let mut current_pid = std::process::id() as pid_t;
89
90 while let Some(parent_pid) = get_parent_pid(current_pid) {
91 let path = get_state_file_path(&dir, parent_pid);
92 if path.exists() {
93 let raw = std::fs::read_to_string(path)?;
94 let value: T = serde_json::from_str(&raw)?;
95 return Ok(Some(value));
96 }
97 current_pid = parent_pid;
98 }
99
100 Ok(None)
101}

Callers 1

create_dwarf_contextMethod · 0.85

Calls 3

get_root_dirFunction · 0.85
get_parent_pidFunction · 0.85
get_state_file_pathFunction · 0.85

Tested by

no test coverage detected