muse2/input/agent/
region.rsuse crate::input::region::{define_region_id_getter, read_regions_for_entity};
use crate::input::HasID;
use crate::region::RegionSelection;
use anyhow::Result;
use serde::Deserialize;
use std::collections::{HashMap, HashSet};
use std::path::Path;
use std::rc::Rc;
const AGENT_REGIONS_FILE_NAME: &str = "agent_regions.csv";
#[derive(Debug, Deserialize, PartialEq)]
struct AgentRegion {
agent_id: String,
region_id: String,
}
define_region_id_getter!(AgentRegion);
impl HasID for AgentRegion {
fn get_id(&self) -> &str {
&self.agent_id
}
}
pub fn read_agent_regions(
model_dir: &Path,
agent_ids: &HashSet<Rc<str>>,
region_ids: &HashSet<Rc<str>>,
) -> Result<HashMap<Rc<str>, RegionSelection>> {
let file_path = model_dir.join(AGENT_REGIONS_FILE_NAME);
read_regions_for_entity::<AgentRegion>(&file_path, agent_ids, region_ids)
}