pub struct TaskTemplate {
pub id: Option<i32>,
pub name: String,
pub task_name: String,
pub comment: String,
pub completeness: i32,
pub created_at: Option<String>,
}Expand description
Represents a reusable task template with predefined values.
A task template serves as a blueprint for creating tasks with consistent properties. Templates encapsulate common task patterns and provide default values that can be used directly or modified during task creation.
§Design Philosophy
Templates separate the template identity (name) from the actual task content (task_name), allowing for readable template names while maintaining flexible task naming. This enables templates like “daily-standup” to create tasks named “Prepare for daily standup meeting”.
§Field Relationships
- name: Identifies the template itself (e.g., “code-review-template”)
- task_name: The actual task title when created (e.g., “Review PR #123”)
- comment: Default description for context and instructions
- completeness: Default progress state (useful for different task types)
Fields§
§id: Option<i32>Database-assigned unique identifier.
Automatically set when the template is saved to the database. Used for internal references and database operations.
name: StringUnique template identifier for human-readable reference.
This is the name users will use to identify and select templates. Must be unique across all templates and should be descriptive of the template’s purpose (e.g., “daily-standup”, “code-review”).
task_name: StringThe actual task name that will be used when creating tasks.
This becomes the task title when a task is created from this template. Can contain placeholders or generic descriptions that users can customize during task creation.
comment: StringDefault description or notes for tasks created from this template.
Provides context, instructions, or checklist items that help users understand what the task involves. Can include formatting and detailed guidance for task execution.
completeness: i32Default completion percentage when tasks are created from this template.
Allows templates to specify different starting completion states:
- 0: For tasks that start completely unfinished
- 50: For tasks that are partially pre-completed
- 100: For tasks that are considered complete when created (e.g., automated tasks)
created_at: Option<String>Timestamp when the template was created.
Automatically managed by the database for audit trails and chronological sorting. Used for template management and history.
Implementations§
Source§impl TaskTemplate
impl TaskTemplate
Sourcepub fn new(
name: String,
task_name: String,
comment: String,
completeness: i32,
) -> Self
pub fn new( name: String, task_name: String, comment: String, completeness: i32, ) -> Self
Creates a new task template with the specified properties.
This constructor creates a template object ready for database insertion.
The ID and creation timestamp are automatically assigned when the
template is saved using the Templates::create() method.
§Arguments
name- Unique identifier for the template (user-facing name)task_name- Default task title for tasks created from this templatecomment- Default description/instructions for template-based taskscompleteness- Default completion percentage (0-100)
§Returns
Returns a new TaskTemplate instance ready for database operations.
§Example
use kasl::db::templates::TaskTemplate;
let template = TaskTemplate::new(
"morning-routine".to_string(),
"Complete morning routine".to_string(),
"Check emails, review calendar, plan day".to_string(),
25 // Start at 25% since some prep is already done
);§Design Considerations
- Template names should be URL-safe and easy to type
- Task names can be more descriptive and user-friendly
- Comments should provide actionable guidance
- Completion values should reflect realistic starting states
Trait Implementations§
Source§impl Clone for TaskTemplate
impl Clone for TaskTemplate
Source§fn clone(&self) -> TaskTemplate
fn clone(&self) -> TaskTemplate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more