pueue_lib/message/
mod.rs

1//! This contains the the [`Request`] and [`Response`]  enums and
2//! all their structs used to communicate with the daemon or client.
3use std::path::PathBuf;
4
5use serde::{Deserialize, Serialize};
6
7use crate::task::Task;
8
9pub mod request;
10pub mod response;
11
12pub use request::*;
13pub use response::*;
14
15#[derive(PartialEq, Eq, Clone, Debug, Deserialize, Serialize)]
16pub struct EditableTask {
17    pub id: usize,
18    #[serde(rename = "command")]
19    pub original_command: String,
20    pub path: PathBuf,
21    pub label: Option<String>,
22    pub priority: i32,
23}
24
25impl From<&Task> for EditableTask {
26    /// Create an editable tasks from any [Task]]
27    fn from(task: &Task) -> Self {
28        EditableTask {
29            id: task.id,
30            original_command: task.original_command.clone(),
31            path: task.path.clone(),
32            label: task.label.clone(),
33            priority: task.priority,
34        }
35    }
36}
37
38impl EditableTask {
39    /// Merge a [EditableTask] back into a [Task].
40    pub fn into_task(self, task: &mut Task) {
41        task.original_command = self.original_command;
42        task.path = self.path;
43        task.label = self.label;
44        task.priority = self.priority;
45    }
46}