MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / storage

Function storage

flow-rs/src/resource/storage.rs:58–75  ·  view source on GitHub ↗
(local_key: u64, id: u64, cfg: &HashMap<String, Entity>)

Source from the content-addressed store, hash-verified

56pub(crate) type ResourceStorage = Mutex<StorageInner>;
57
58pub(crate) fn storage(local_key: u64, id: u64, cfg: &HashMap<String, Entity>) -> ResourceStorage {
59 let mut resources = HashMap::new();
60 for (name, res) in cfg {
61 let slice = ResourceSlice::registry_local()
62 .get(local_key)
63 .get(&res.ty)
64 .unwrap();
65 let name_cloned = name.clone();
66 let args_cloned = res.args.clone();
67 resources.insert(
68 (id, name.clone()),
69 LazyCell::new(Box::new(move || {
70 (slice.cons)(name_cloned.clone(), &args_cloned)
71 })),
72 );
73 }
74 Mutex::new(StorageInner { resources })
75}

Callers 1

newMethod · 0.85

Calls 3

insertMethod · 0.80
getMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected