MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / merge_map

Function merge_map

crates/openshell-server/src/grpc/provider.rs:390–405  ·  view source on GitHub ↗

Merge an incoming map into an existing map. - If `incoming` is empty, return `existing` unchanged (no-op). - Otherwise, upsert all incoming entries into `existing`. - Entries with an empty-string value are removed (delete semantics).

(
    mut existing: std::collections::HashMap<String, String>,
    incoming: std::collections::HashMap<String, String>,
)

Source from the content-addressed store, hash-verified

388/// - Otherwise, upsert all incoming entries into `existing`.
389/// - Entries with an empty-string value are removed (delete semantics).
390fn merge_map(
391 mut existing: std::collections::HashMap<String, String>,
392 incoming: std::collections::HashMap<String, String>,
393) -> std::collections::HashMap<String, String> {
394 if incoming.is_empty() {
395 return existing;
396 }
397 for (key, value) in incoming {
398 if value.is_empty() {
399 existing.remove(&key);
400 } else {
401 existing.insert(key, value);
402 }
403 }
404 existing
405}
406
407fn merge_i64_map(
408 mut existing: std::collections::HashMap<String, i64>,

Callers 1

update_provider_recordFunction · 0.85

Calls 2

is_emptyMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected