Skip to main content

immich_lib/models/
asset.rs

1//! Asset response types.
2
3use serde::{Deserialize, Serialize};
4
5use super::exif::ExifInfo;
6
7/// Type of asset (image or video).
8#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
9#[serde(rename_all = "UPPERCASE")]
10pub enum AssetType {
11    /// Image file (JPEG, PNG, HEIC, etc.)
12    Image,
13
14    /// Video file (MP4, MOV, etc.)
15    Video,
16}
17
18/// Asset response from the Immich API.
19#[derive(Debug, Clone, Deserialize, Serialize)]
20#[serde(rename_all = "camelCase")]
21pub struct AssetResponse {
22    /// Unique asset identifier
23    pub id: String,
24
25    /// Original filename when uploaded
26    pub original_file_name: String,
27
28    /// File creation timestamp (UTC)
29    pub file_created_at: String,
30
31    /// Local date/time (timezone-aware)
32    pub local_date_time: String,
33
34    /// Asset type (image or video)
35    #[serde(rename = "type")]
36    pub asset_type: AssetType,
37
38    /// EXIF metadata (may be absent)
39    pub exif_info: Option<ExifInfo>,
40
41    /// SHA-1 checksum (base64 encoded)
42    pub checksum: String,
43
44    /// Whether the asset is in trash
45    pub is_trashed: bool,
46
47    /// Whether the asset is marked as favorite
48    pub is_favorite: bool,
49
50    /// Whether the asset is archived
51    pub is_archived: bool,
52
53    /// Whether the asset has metadata
54    pub has_metadata: bool,
55
56    /// Duration string (e.g., "0:00:00.000000" for images)
57    pub duration: String,
58
59    /// Owner user ID
60    pub owner_id: String,
61
62    /// Original MIME type (optional)
63    #[serde(default)]
64    pub original_mime_type: Option<String>,
65
66    /// Duplicate group ID (null if not a duplicate)
67    #[serde(default)]
68    pub duplicate_id: Option<String>,
69
70    /// Thumbhash for quick preview (nullable)
71    #[serde(default)]
72    pub thumbhash: Option<String>,
73}
74
75impl AssetResponse {
76    /// Returns true if this asset has any EXIF metadata
77    pub fn has_exif(&self) -> bool {
78        self.exif_info.is_some()
79    }
80}