use introspection_core::{StatusSnapshot, TopicStatus};
pub fn find_topic_status<'a>(snapshot: &'a StatusSnapshot, name: &str) -> Option<&'a TopicStatus> {
snapshot
.topics
.iter()
.find(|topic| topic_matches(&topic.name, name))
}
pub fn topic_matches(candidate: &str, input: &str) -> bool {
candidate == input || candidate.ends_with(&format!("/{input}"))
}
pub fn utilization_percent(pending: usize, max_depth: usize) -> f64 {
if max_depth == 0 {
return 0.0;
}
(pending as f64 / max_depth as f64) * 100.0
}