Skip to main content

TaskTemplate

Struct TaskTemplate 

Source
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: String

Unique 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: String

The 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: String

Default 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: i32

Default 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

Source

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 template
  • comment - Default description/instructions for template-based tasks
  • completeness - 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

Source§

fn clone(&self) -> TaskTemplate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskTemplate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TaskTemplate

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TaskTemplate

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more