Skip to main content

videre_api/
types.rs

1use serde::Serialize;
2
3/// One labeled person: their confirmed faces plus a representative face id
4/// (the primary, or lowest id) used as the card thumbnail.
5#[derive(Serialize, Clone)]
6pub struct PersonData {
7    /// Identity: normalized, what URLs and actions use.
8    pub label: String,
9    /// What a reader sees. Falls back to `label` for a person whose row
10    /// predates the people table.
11    pub full_name: String,
12    pub face_ids: Vec<i64>,
13    pub representative_id: i64,
14    pub hashes: Vec<String>,
15}
16
17/// One unassigned cluster (green section in the labeling UI).
18#[derive(Serialize, Clone)]
19pub struct ClusterData {
20    pub cluster_id: i64,
21    pub face_ids: Vec<i64>,
22    pub hashes: Vec<String>,
23}
24
25/// One unclustered, unassigned face (orange section).
26#[derive(Serialize, Clone)]
27pub struct SingletonData {
28    pub face_id: i64,
29    pub hash: String,
30}
31
32/// Top-level payload for the labeling page.
33///
34/// `Default` is the "detection has never run" answer, which is a state rather
35/// than an error. See `faces_list`.
36#[derive(Serialize, Clone, Default)]
37pub struct FacesData {
38    pub people: Vec<PersonData>,
39    pub clusters: Vec<ClusterData>,
40    pub singletons: Vec<SingletonData>,
41}
42
43/// One face row on a cluster detail page.
44#[derive(Serialize, Clone)]
45pub struct ClusterFaceData {
46    pub face_id: i64,
47    pub hash: String,
48    pub path: String,
49}
50
51/// Cluster detail: every face in one unassigned cluster.
52#[derive(Serialize, Clone)]
53pub struct ClusterDetail {
54    pub cluster_id: i64,
55    pub faces: Vec<ClusterFaceData>,
56}
57
58/// One face row on a person detail page. `is_primary` marks the current
59/// default photo (the person's thumbnail on the labeling page).
60#[derive(Serialize, Clone)]
61pub struct PersonFaceData {
62    pub face_id: i64,
63    pub hash: String,
64    pub path: String,
65    pub is_primary: bool,
66}
67
68/// Person detail: every confirmed face for one person.
69#[derive(Serialize, Clone)]
70pub struct PersonDetail {
71    /// Identity: what the URL and every face row use.
72    pub label: String,
73    /// What a reader sees, and what the page lets them edit.
74    pub full_name: String,
75    pub faces: Vec<PersonFaceData>,
76}