MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_cluster_secret

Function read_cluster_secret

nodedb/src/ctl/join_token.rs:48–61  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

46}
47
48fn read_cluster_secret(path: &Path) -> Result<[u8; CLUSTER_SECRET_LEN], String> {
49 let bytes =
50 fs::read(path).map_err(|e| format!("read cluster secret {}: {e}", path.display()))?;
51 if bytes.len() != CLUSTER_SECRET_LEN {
52 return Err(format!(
53 "cluster secret {} has {} bytes, expected {CLUSTER_SECRET_LEN}",
54 path.display(),
55 bytes.len()
56 ));
57 }
58 let mut out = [0u8; CLUSTER_SECRET_LEN];
59 out.copy_from_slice(&bytes);
60 Ok(out)
61}
62
63#[cfg(test)]
64mod tests {

Callers 1

createFunction · 0.70

Calls 2

readFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected