rusty_beads/types/
comment.rs

1//! Comment type definition.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// A comment on an issue.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Comment {
9    /// Unique comment ID.
10    pub id: i64,
11    /// Parent issue ID.
12    pub issue_id: String,
13    /// Comment author.
14    pub author: String,
15    /// Comment content.
16    pub text: String,
17    /// When the comment was posted.
18    pub created_at: DateTime<Utc>,
19}
20
21impl Comment {
22    /// Create a new comment.
23    pub fn new(
24        id: i64,
25        issue_id: impl Into<String>,
26        author: impl Into<String>,
27        text: impl Into<String>,
28    ) -> Self {
29        Self {
30            id,
31            issue_id: issue_id.into(),
32            author: author.into(),
33            text: text.into(),
34            created_at: Utc::now(),
35        }
36    }
37}