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

Function sanitize_denials_by_group

crates/openshell-core/src/telemetry.rs:593–613  ·  view source on GitHub ↗
(denials_by_group: I)

Source from the content-addressed store, hash-verified

591}
592
593fn sanitize_denials_by_group<I>(denials_by_group: I) -> Option<BTreeMap<DenyGroup, u64>>
594where
595 I: IntoIterator<Item = (DenyGroup, u64)>,
596{
597 let mut sanitized = BTreeMap::<DenyGroup, u64>::new();
598 for (group, count) in denials_by_group {
599 if !valid_count(count) {
600 return None;
601 }
602 let next_count = sanitized
603 .get(&group)
604 .copied()
605 .unwrap_or(0)
606 .checked_add(count)?;
607 if !valid_count(next_count) {
608 return None;
609 }
610 sanitized.insert(group, next_count);
611 }
612 Some(sanitized)
613}
614
615#[cfg(all(test, feature = "telemetry"))]
616mod tests {

Calls 2

valid_countFunction · 0.85
getMethod · 0.45