1use crate::record::RecordId;
2
3pub type EntityId = u64;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
7pub enum ResolutionMethod {
8 AutoMatch,
9 JudgePromoted,
10 JudgeDemoted,
11 Manual,
12}
13
14#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
16pub struct EntityMember {
17 pub record_id: RecordId,
18 pub score: f32,
19 pub method: ResolutionMethod,
20 pub source: Option<String>,
21}
22
23#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
25pub struct Entity {
26 pub id: EntityId,
27 pub members: Vec<EntityMember>,
28}
29
30impl Entity {
31 pub fn new(id: EntityId) -> Self {
32 Self { id, members: vec![] }
33 }
34
35 pub fn member_ids(&self) -> impl Iterator<Item = RecordId> + '_ {
36 self.members.iter().map(|m| m.record_id)
37 }
38}