primitives.rs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. use serde::{Deserialize, Serialize};
  2. use darkfi::util::Timestamp;
  3. #[derive(Debug, Clone, Deserialize, Serialize)]
  4. pub struct TaskInfo {
  5. pub ref_id: String,
  6. pub id: u32,
  7. pub title: String,
  8. pub desc: String,
  9. pub owner: String,
  10. pub assign: Vec<String>,
  11. pub project: Vec<String>,
  12. pub due: Option<i64>,
  13. pub rank: f32,
  14. pub created_at: i64,
  15. pub events: Vec<TaskEvent>,
  16. pub comments: Vec<Comment>,
  17. }
  18. #[derive(Clone, Debug, Serialize, Deserialize)]
  19. pub struct TaskEvent {
  20. pub action: String,
  21. pub timestamp: Timestamp,
  22. }
  23. impl std::fmt::Display for TaskEvent {
  24. fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
  25. write!(f, "action: {}, timestamp: {}", self.action, self.timestamp)
  26. }
  27. }
  28. impl Default for TaskEvent {
  29. fn default() -> Self {
  30. TaskEvent {
  31. action: "open".to_string(),
  32. timestamp: Timestamp(chrono::offset::Local::now().timestamp()),
  33. }
  34. }
  35. }
  36. #[derive(Clone, Debug, Serialize, Deserialize)]
  37. pub struct Comment {
  38. content: String,
  39. author: String,
  40. timestamp: Timestamp,
  41. }
  42. impl std::fmt::Display for Comment {
  43. fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
  44. write!(f, "{} author: {}, content: {} ", self.timestamp, self.author, self.content)
  45. }
  46. }