Skip to main content

capsule_library/db/
rows.rs

1#[derive(Debug, Clone, PartialEq)]
2pub struct AssetRow {
3    pub uuid: String,
4    pub asset_type: String,
5    pub capture_timestamp: i64,
6    pub capture_utc: Option<i64>,
7    pub capture_tz_source: Option<String>,
8    pub import_timestamp: i64,
9    pub hash_sha256: String,
10    pub width: Option<i64>,
11    pub height: Option<i64>,
12    pub duration_ms: Option<i64>,
13    pub stack_id: Option<String>,
14    pub is_stack_hidden: bool,
15    pub chromahash: Option<String>,
16    pub dominant_color: Option<String>,
17    pub album_id: Option<String>,
18    pub rating: i64,
19    pub is_deleted: bool,
20    pub deleted_at: Option<i64>,
21    /// Projection of the sidecar `hidden` LWW register (SSoT: design/organization
22    /// § Hidden Assets). Excluded from every default view; served only by the gated
23    /// Hidden view. Distinct from `is_stack_hidden`, which suppresses non-primary
24    /// members of a collapsed stack.
25    pub is_hidden: bool,
26    /// Projection of the sidecar `caption` LWW register. `None` is no caption; an empty
27    /// caption is stored as `None`.
28    pub caption: Option<String>,
29    /// Latitude of the sidecar's effective location (`gps_user` over the as-imported `gps`),
30    /// in signed decimal degrees, verbatim in the sidecar's datum.
31    pub latitude: Option<f64>,
32    /// Longitude of the same effective location; `None` exactly when `latitude` is.
33    pub longitude: Option<f64>,
34}
35
36#[derive(Debug, Clone, PartialEq)]
37pub struct AssetStackRow {
38    pub id: String,
39    pub stack_type: String,
40    pub primary_asset_id: String,
41    pub cover_asset_id: Option<String>,
42    pub is_collapsed: bool,
43    pub is_auto_generated: bool,
44    pub created_at: i64,
45    pub modified_at: i64,
46}
47
48#[derive(Debug, Clone, PartialEq)]
49pub struct StackMemberRow {
50    pub id: String,
51    pub stack_id: String,
52    pub asset_id: String,
53    pub sequence_order: i64,
54    pub member_role: String,
55    pub created_at: i64,
56}
57
58#[derive(Debug, Clone, PartialEq)]
59pub struct AssetTagRow {
60    pub uuid: String,
61    pub tag: String,
62}
63
64/// A user-defined album. Membership is tracked via `assets.album_id`
65/// (one album per asset, per the filesystem design doc).
66#[derive(Debug, Clone, PartialEq)]
67pub struct AlbumRow {
68    pub id: String,
69    pub name: String,
70    pub created_at: i64,
71    pub modified_at: i64,
72    pub cover_asset_id: Option<String>,
73}
74
75/// One cached, reclaimable representation of an asset. The eviction sweep ranks these by
76/// `last_accessed_at` (LRU) with `tier` as the tiebreaker; `pinned` and `is_owned_original`
77/// rows are exempt. `path` is the on-disk cache file the sweep deletes.
78#[derive(Debug, Clone, PartialEq)]
79pub struct CachedRepresentationRow {
80    pub uuid: String,
81    /// `"original"` | `"preview"` | `"thumbnail"`.
82    pub tier: String,
83    pub format: Option<String>,
84    pub bytes: i64,
85    pub path: String,
86    pub last_accessed_at: i64,
87    pub pinned: bool,
88    /// An original this device itself owns as source of truth — never auto-evicted.
89    pub is_owned_original: bool,
90}