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

Function register

src/shell_session_store.rs:72–82  ·  view source on GitHub ↗

Persist `value` for the current shell session (keyed by the parent PID of this process).

(kind: SessionKind, value: &T)

Source from the content-addressed store, hash-verified

70/// Persist `value` for the current shell session (keyed by the parent PID of
71/// this process).
72pub(crate) fn register<T: Serialize>(kind: SessionKind, value: &T) -> Result<()> {
73 let dir = get_root_dir(kind);
74 std::fs::create_dir_all(&dir)?;
75
76 let parent_pid =
77 get_parent_pid(std::process::id() as pid_t).context("Could not determine parent PID")?;
78
79 let path = get_state_file_path(&dir, parent_pid);
80 std::fs::write(path, serde_json::to_string(value)?)?;
81 Ok(())
82}
83
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.

Callers 2

Calls 3

get_root_dirFunction · 0.85
get_parent_pidFunction · 0.85
get_state_file_pathFunction · 0.85

Tested by

no test coverage detected