(policy: &SandboxPolicy, preferred: &str)
| 75 | } |
| 76 | |
| 77 | fn unique_provider_rule_key(policy: &SandboxPolicy, preferred: &str) -> String { |
| 78 | if !policy.network_policies.contains_key(preferred) { |
| 79 | return preferred.to_string(); |
| 80 | } |
| 81 | |
| 82 | for suffix in 2_u32.. { |
| 83 | let candidate = format!("{preferred}_{suffix}"); |
| 84 | if !policy.network_policies.contains_key(&candidate) { |
| 85 | return candidate; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | unreachable!("unbounded suffix search must find an unused provider policy key") |
| 90 | } |
| 91 | |
| 92 | #[cfg(test)] |
| 93 | mod tests { |
no test coverage detected