Skip to main content

videre_api/
types.rs

1use serde::Serialize;
2
3/// Versioned model context attached to evidence captured by a Gallery action.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct TeachingContext {
6    pub embedding_model_id: String,
7    pub active_profile_id: Option<i64>,
8}
9
10/// Durable learning work committed with a visible people mutation.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
12pub struct LearningAcknowledgement {
13    pub generation: u64,
14    pub event_ids: Vec<i64>,
15    pub message_key: String,
16}
17
18/// Learning status for the gallery background worker.
19#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
20pub struct FaceLearningStatus {
21    pub generation: u64,
22    pub trained_generation: u64,
23    pub status: String,
24    pub last_profile_id: Option<i64>,
25    /// What became of the last trained candidate: `promoted` or `rejected`,
26    /// or `None` before any candidate was stored. Lets a `current` status
27    /// say whether the last run changed the profile in use.
28    pub last_candidate: Option<String>,
29    pub last_error: Option<String>,
30    pub pending_questions: usize,
31}
32
33/// The stored outcome of one background training run.
34#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
35pub struct TrainedProfileSummary {
36    pub profile_id: i64,
37    pub model_kind: String,
38    pub promoted: bool,
39}
40
41/// Result of answering one identity question: the new delivery state and, for
42/// Yes and No, the durable learning work the answer committed.
43#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
44pub struct QuestionAnswerOutcome {
45    pub status: String,
46    pub acknowledgement: Option<LearningAcknowledgement>,
47}
48
49/// One labeled person: their confirmed faces plus a representative face id
50/// (the primary, or lowest id) used as the card thumbnail.
51#[derive(Serialize, Clone)]
52pub struct PersonData {
53    /// Identity: normalized, what URLs and actions use.
54    pub label: String,
55    /// What a reader sees. Falls back to `label` for a person whose row
56    /// predates the people table.
57    pub full_name: String,
58    pub face_ids: Vec<i64>,
59    pub representative_id: i64,
60    pub hashes: Vec<String>,
61}
62
63/// One unassigned cluster (green section in the labeling UI).
64#[derive(Serialize, Clone)]
65pub struct ClusterData {
66    pub cluster_id: i64,
67    pub face_ids: Vec<i64>,
68    pub hashes: Vec<String>,
69}
70
71/// One unclustered, unassigned face (orange section).
72#[derive(Serialize, Clone)]
73pub struct SingletonData {
74    pub face_id: i64,
75    pub hash: String,
76}
77
78/// Top-level payload for the labeling page.
79///
80/// `Default` is the "detection has never run" answer, which is a state rather
81/// than an error. See `faces_list`.
82#[derive(Serialize, Clone, Default)]
83pub struct FacesData {
84    pub people: Vec<PersonData>,
85    pub clusters: Vec<ClusterData>,
86    pub singletons: Vec<SingletonData>,
87}
88
89/// One face row on a cluster detail page.
90#[derive(Serialize, Clone)]
91pub struct ClusterFaceData {
92    pub face_id: i64,
93    pub hash: String,
94    pub path: String,
95}
96
97/// Cluster detail: every face in one unassigned cluster.
98#[derive(Serialize, Clone)]
99pub struct ClusterDetail {
100    pub cluster_id: i64,
101    pub faces: Vec<ClusterFaceData>,
102}
103
104/// One face row on a person detail page. `is_primary` marks the current
105/// default photo (the person's thumbnail on the labeling page).
106#[derive(Serialize, Clone)]
107pub struct PersonFaceData {
108    pub face_id: i64,
109    pub hash: String,
110    pub path: String,
111    pub is_primary: bool,
112}
113
114/// Person detail: every confirmed face for one person.
115#[derive(Serialize, Clone)]
116pub struct PersonDetail {
117    /// Identity: what the URL and every face row use.
118    pub label: String,
119    /// What a reader sees, and what the page lets them edit.
120    pub full_name: String,
121    pub faces: Vec<PersonFaceData>,
122}