Skip to main content

client_core/store/
models.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
4pub struct StoredClip {
5    pub id: String, // ULID
6    pub source: String,
7    pub source_key: Option<String>,
8    pub content_type: String,
9    pub content: Option<Vec<u8>>,
10    pub media_path: Option<String>,
11    pub byte_size: i64,
12    pub created_at: i64, // unix ms
13    pub pinned: bool,
14    pub pinned_at: Option<i64>,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
18pub struct StoredDevice {
19    pub id: String,
20    pub hostname: String,
21    pub nickname: Option<String>,
22    pub source_key: Option<String>,
23    pub machine_id: Option<String>,
24    pub public_key: Option<String>,
25    pub paired_at: Option<i64>,
26    pub last_push_at: Option<i64>,
27    pub online: bool,
28    pub refreshed_at: i64,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
32pub struct SourceRow {
33    pub source: String,
34    pub clip_count: i64,
35    pub last_seen: Option<i64>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
39pub struct RetentionPref {
40    pub device_id: String,
41    pub days: i64,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
45pub struct AlertPref {
46    pub source: String,
47    pub enabled: bool,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
51pub struct MatchInfo {
52    pub id: String,
53    pub source: String,
54    pub content_type: String,
55    pub created_at: i64,
56    pub preview: String, // first 40 chars of content or "[binary type ยท NkB]"
57}
58
59#[derive(Debug, thiserror::Error)]
60pub enum ResolveError {
61    #[error("prefix must be at least 4 characters")]
62    TooShort,
63    #[error("no match found")]
64    NotFound,
65    #[error("ambiguous prefix; {} candidates", .candidates.len())]
66    Ambiguous { candidates: Vec<MatchInfo> },
67    #[error("store error: {0}")]
68    Store(#[from] super::StoreError),
69}