MCPcopy Index your code
hub / github.com/eventuallyconsultant/codegenr / ensure_orignal_json

Function ensure_orignal_json

codegenr/src/resolver.rs:37–48  ·  view source on GitHub ↗
(doc_path: &DocumentPath, original_cache: &mut OriginalDocumentsHash)

Source from the content-addressed store, hash-verified

35
36fn ensure_orignal_json(doc_path: &DocumentPath, original_cache: &mut OriginalDocumentsHash) -> Result<Rc<Value>, ResolverError> {
37 use std::collections::hash_map::Entry::*;
38 match original_cache.entry(doc_path.clone()) {
39 Occupied(entry) => Ok(entry.get().clone()),
40 Vacant(entry) => {
41 let json = doc_path.load_raw()?;
42 let rc = Rc::new(json);
43 entry.insert(rc.clone());
44 Ok(rc)
45 }
46 }
47}
48
49fn get_resolved_json(doc_path: &DocumentPath, resolved_cache: &mut ResolvedDocumentsHash) -> Option<Rc<Value>> {
50 resolved_cache.get(doc_path).cloned()
51}

Callers 1

get_resolved_or_originalFunction · 0.85

Calls 1

load_rawMethod · 0.80

Tested by

no test coverage detected