pub struct Task {
pub id: Option<i32>,
pub task_id: Option<i32>,
pub timestamp: Option<String>,
pub name: String,
pub comment: String,
pub completeness: Option<i32>,
pub excluded_from_search: Option<bool>,
pub tags: Vec<Tag>,
}Expand description
A single work item.
task_id links to an external system (a Jira issue id, a GitLab MR);
timestamp is managed by the database layer.
use kasl::libs::task::Task;
let task = Task::new(
"Code review for PR #123",
"Review authentication changes and security implications",
Some(0) // Just started
);use kasl::libs::task::Task;
let existing_task = Task::new("Existing task", "Details", Some(50));
let mut task = existing_task;
task.completeness = Some(75);
task.comment = "Almost finished, testing remaining".to_string();Populating a task from an external issue:
use kasl::libs::task::Task;
// Simulated Jira issue data used to populate a task.
let jira_issue_id = 42;
struct JiraIssue {
summary: String,
description: Option<String>,
}
let jira_issue = JiraIssue {
summary: "Fix login bug".to_string(),
description: Some("Users cannot log in with SSO".to_string()),
};
let jira_task = Task {
id: None, // Will be assigned by database
task_id: Some(jira_issue_id),
timestamp: None,
name: jira_issue.summary,
comment: jira_issue.description.unwrap_or_default(),
completeness: Some(100), // Imported completed issues
excluded_from_search: None,
tags: vec![],
};Fields§
§id: Option<i32>Database primary key; None until the task is saved.
task_id: Option<i32>External reference (Jira issue id, GitLab MR id); None for standalone tasks.
timestamp: Option<String>"YYYY-MM-DD HH:MM:SS" in local time, set by the database layer.
name: StringTask title.
comment: StringFree-form notes.
completeness: Option<i32>Progress 0-100; imported completed issues default to 100.
excluded_from_search: Option<bool>Hidden from task discovery when true.
Tags, maintained through the task_tags relationship table.
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(name: &str, comment: &str, completeness: Option<i32>) -> Self
pub fn new(name: &str, comment: &str, completeness: Option<i32>) -> Self
Creates an unsaved task; whitespace in name and comment is collapsed.
use kasl::libs::task::Task;
let new_task = Task::new(
"Implement user registration",
"Add email verification and password validation",
Some(0)
);
let completed_task = Task::new(
"Fix login redirect bug",
"Resolved issue with OAuth callback URL handling",
Some(100)
);
let planning_task = Task::new(
"Research authentication libraries",
"Evaluate OAuth2 libraries for Node.js backend",
None
);Sourcepub fn update_from(&mut self, other: &Task)
pub fn update_from(&mut self, other: &Task)
Copies name, comment and completeness from other, keeping
identity fields (id, task_id, timestamp, search flag, tags).
use kasl::libs::task::Task;
use kasl::db::tasks::Tasks;
let mut tasks_db = Tasks::new()?;
let mut existing_task = tasks_db.get_by_id(42)?.expect("task exists");
let updated_task = Task::new(
"Updated task name",
"Updated description with new requirements",
Some(75)
);
existing_task.update_from(&updated_task);
tasks_db.update(&existing_task)?;use kasl::libs::task::Task;
use kasl::db::tasks::Tasks;
let mut tasks_db = Tasks::new()?;
let tasks_to_update: Vec<Task> = vec![];
let get_update_template = |_task: &Task| -> Option<Task> { None };
for mut task in tasks_to_update {
if let Some(template) = get_update_template(&task) {
task.update_from(&template);
tasks_db.update(&task)?;
}
}use kasl::libs::task::Task;
let mut original_task = Task::new(
"Original task",
"Original description",
Some(25)
);
original_task.id = Some(42);
let updated_task = Task::new(
"Updated task name",
"Updated description with more details",
Some(75)
);
original_task.update_from(&updated_task);
assert_eq!(original_task.id, Some(42)); // ID preserved
assert_eq!(original_task.name, "Updated task name"); // Content updated
assert_eq!(original_task.completeness, Some(75)); // Progress updatedTrait Implementations§
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more