Expand description
Facade over videre’s faces-labeling operations. Plain functions over an
open rusqlite::Connection, returning serde types and a shared Error.
Transport-agnostic on purpose: the axum --faces server is the in-repo
caller, but nothing here depends on it.
Structs§
- Cluster
Data - One unassigned cluster (green section in the labeling UI).
- Cluster
Detail - Cluster detail: every face in one unassigned cluster.
- Cluster
Face Data - One face row on a cluster detail page.
- Face
Lookup - The single-row query
face_image_bytesneeds before it can do any image work, split out so a caller holding a shared/lockedConnection(the axum server serializes every request on oneMutex<Connection>) can release that lock immediately after this cheap lookup, instead of holding it for the entire decode/crop/resize/encode/cache-write below, which otherwise fully serializes every thumbnail request behind the lock, turning a many-thousand-singleton library into one thumbnail at a time. - Faces
Data - Top-level payload for the labeling page.
- Library
Stats - Original
Lookup - The single-row query
original_image_bytesneeds before any image I/O. SeeFaceLookupfor why this split matters for concurrency. - Person
Data - One labeled person: their confirmed faces plus a representative face id (the primary, or lowest id) used as the card thumbnail.
- Person
Detail - Person detail: every confirmed face for one person.
- Person
Face Data - One face row on a person detail page.
is_primarymarks the current default photo (the person’s thumbnail on the labeling page). - Pipeline
RunStatus - Singleton
Data - One unclustered, unassigned face (orange section).
Enums§
- Error
- Errors returned by videre-api operations. Each consumer maps these to its own convention (axum -> StatusCode, other embedders -> their own error type).
Functions§
- assign
- Assign faces to an existing/new person: sets person_label + confirmed. Rejects an empty label after sanitizing.
- cluster_
detail - Every face in one unassigned cluster (for the cluster detail page).
- delete_
person - Reset every face of a person back to unassigned. Deliberately does NOT touch cluster_id, so a face rejoins its cluster’s unassigned group rather than scattering to singletons.
- dissolve_
cluster - Ungroup a bad cluster: its faces become unassigned singletons (not deleted).
- face_
bytes_ from_ lookup - The expensive part of
face_image_bytes: cache check, decode/crop/encode, write-through. Takes noConnection, so it can run without holding the shared DB lock. - face_
image_ bytes - JPEG bytes for a single aligned face thumbnail (140px), reading the disk
cache first and converting from the source image (HEIC via QuickLook) on a
miss, writing through to the cache. Returns
Error::NotFoundif the face id is unknown or the crop cannot be produced. Synchronous: callers that need async should run this on a blocking thread. - face_
lookup - The cheap part of
face_image_bytes: just the DB row. No image I/O. - faces_
list - People / unassigned clusters / singletons for the labeling page.
- library_
stats - make_
face_ thumb - Load, crop, and orientation-correct a face thumbnail.
- mime_
for_ ext - new_
person - Create a person from faces. Same effect as
assign; kept as a distinct operation because callers treat “new person” and “assign to existing” as separate user intents. - original_
bytes_ from_ lookup - The expensive part of
original_image_bytes: read/convert/cache. Takes noConnection, so it can run without holding the shared DB lock. - original_
image_ bytes - Bytes for the full original image behind a face (raw for common formats,
QuickLook-converted JPEG for HEIC, with the HEIC result cached). Returns the
MIME type alongside the bytes.
Error::NotFoundif the id is unknown or the file cannot be read/converted. Synchronous. - original_
lookup - The cheap part of
original_image_bytes: just the DB row. No image I/O. - person_
detail - Every confirmed face for one person, primary first and flagged.
- pipeline_
status - remove_
face - Reset one face to fully unassigned (cluster, label, confirmed, primary).
- rename_
person - Rename a person.
NotFoundifold_labelhas no faces;Conflictifnew_label(after sanitizing) already belongs to a different person;Invalidif the new label sanitizes to empty. - sanitize_
person_ label - Trim, collapse internal whitespace, and cap length (60 code points) so a caller that bypasses UI sanitization can’t stretch layout or bloat the DB. Returns None when nothing usable remains. Filters control and bidi/ zero-width format characters but deliberately keeps U+200C (ZWNJ) and U+200D (ZWJ), which are required for Persian/Indic text and emoji ZWJ sequences. Not homoglyph-proof, and the cap truncates by code point.
- search_
person - Image paths for confirmed faces of a person (prefix match), for the person-name autocomplete. Delegates to the existing core search.
- set_
primary - Mark one face as the person’s primary (their labeling-page thumbnail), clearing any previous primary in the same transaction so exactly one remains. The target update is guarded by person_label so it can’t steal a face from another person.