troll-patrol/src/analyzer.rs

23 lines
726 B
Rust

use crate::BridgeInfo;
use std::collections::HashSet;
/// Provides a function for predicting which countries block this bridge
pub trait Analyzer {
fn blocked_in(&self, bridge_info: &BridgeInfo, confidence: f64) -> HashSet<String>;
}
pub struct ExampleAnalyzer {}
/// Dummy example which just tells us about blockages we already know about
impl Analyzer for ExampleAnalyzer {
fn blocked_in(&self, bridge_info: &BridgeInfo, confidence: f64) -> HashSet<String> {
let mut blocked_in = HashSet::<String>::new();
for (country, info) in &bridge_info.info_by_country {
if info.blocked {
blocked_in.insert(country.to_string());
}
}
blocked_in
}
}