Skip to main content

remem/workstream/
types.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4#[serde(rename_all = "lowercase")]
5pub enum WorkStreamStatus {
6    Active,
7    Paused,
8    Completed,
9    Abandoned,
10}
11
12impl WorkStreamStatus {
13    pub fn as_str(&self) -> &'static str {
14        match self {
15            Self::Active => "active",
16            Self::Paused => "paused",
17            Self::Completed => "completed",
18            Self::Abandoned => "abandoned",
19        }
20    }
21
22    pub fn from_db(s: &str) -> Self {
23        match s {
24            "paused" => Self::Paused,
25            "completed" => Self::Completed,
26            "abandoned" => Self::Abandoned,
27            _ => Self::Active,
28        }
29    }
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct WorkStream {
34    pub id: i64,
35    pub project: String,
36    pub title: String,
37    pub description: Option<String>,
38    pub status: WorkStreamStatus,
39    pub progress: Option<String>,
40    pub next_action: Option<String>,
41    pub blockers: Option<String>,
42    pub created_at_epoch: i64,
43    pub updated_at_epoch: i64,
44    pub completed_at_epoch: Option<i64>,
45}
46
47#[derive(Debug, Clone)]
48pub struct ParsedWorkStream {
49    pub title: Option<String>,
50    pub progress: Option<String>,
51    pub next_action: Option<String>,
52    pub blockers: Option<String>,
53    pub is_completed: bool,
54}
55
56#[derive(Debug, Clone, PartialEq, Eq)]
57pub struct WorkStreamUpsertResult {
58    pub id: i64,
59    pub match_reason: &'static str,
60}
61
62#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63pub struct WorkStreamMergeResult {
64    pub canonical_id: i64,
65    pub merged_ids: Vec<i64>,
66    pub moved_session_links: usize,
67    pub copied_aliases: usize,
68    pub copied_alias_sources: usize,
69}