Task

Struct Task 

Source
pub struct Task {
Show 17 fields pub id: TaskId, pub name: String, pub summary: Option<String>, pub effort: Option<Duration>, pub duration: Option<Duration>, pub depends: Vec<Dependency>, pub assigned: Vec<ResourceRef>, pub priority: u32, pub constraints: Vec<TaskConstraint>, pub milestone: bool, pub children: Vec<Task>, pub complete: Option<f32>, pub actual_start: Option<NaiveDate>, pub actual_finish: Option<NaiveDate>, pub explicit_remaining: Option<Duration>, pub status: Option<TaskStatus>, pub attributes: HashMap<String, String>,
}
Expand description

A schedulable unit of work

Fields§

§id: TaskId

Unique identifier

§name: String

Human-readable description (from quoted string in DSL)

§summary: Option<String>

Optional short display name (MS Project “Task Name” style)

§effort: Option<Duration>

Work effort required (person-time)

§duration: Option<Duration>

Calendar duration (overrides effort-based calculation)

§depends: Vec<Dependency>

Task dependencies

§assigned: Vec<ResourceRef>

Resource assignments

§priority: u32

Scheduling priority (higher = scheduled first)

§constraints: Vec<TaskConstraint>

Scheduling constraints

§milestone: bool

Is this a milestone (zero duration)?

§children: Vec<Task>

Child tasks (WBS hierarchy)

§complete: Option<f32>

Completion percentage (for tracking)

§actual_start: Option<NaiveDate>

Actual start date (when work actually began)

§actual_finish: Option<NaiveDate>

Actual finish date (when work actually completed)

§explicit_remaining: Option<Duration>

Explicit remaining duration (overrides linear calculation from complete%) When set, this takes precedence over duration * (1 - complete/100)

§status: Option<TaskStatus>

Task status for progress tracking

§attributes: HashMap<String, String>

Custom attributes

Implementations§

Source§

impl Task

Source

pub fn new(id: impl Into<String>) -> Self

Create a new task with the given ID

Source

pub fn name(self, name: impl Into<String>) -> Self

Set the task name

Source

pub fn summary(self, summary: impl Into<String>) -> Self

Set the task summary (short display name)

Source

pub fn effort(self, effort: Duration) -> Self

Set the effort

Source

pub fn duration(self, duration: Duration) -> Self

Set the duration

Source

pub fn depends_on(self, predecessor: impl Into<String>) -> Self

Add a dependency (FinishToStart by default)

Source

pub fn with_dependency(self, dep: Dependency) -> Self

Add a dependency with full control over type and lag

Source

pub fn assign(self, resource: impl Into<String>) -> Self

Assign a resource

Source

pub fn assign_with_units(self, resource: impl Into<String>, units: f32) -> Self

Assign a resource with specific allocation units

Units represent allocation percentage: 1.0 = 100%, 0.5 = 50%, etc. This affects effort-driven duration calculation: Duration = Effort / Total_Units

Source

pub fn priority(self, priority: u32) -> Self

Set priority

Source

pub fn milestone(self) -> Self

Mark as milestone

Source

pub fn child(self, child: Task) -> Self

Add a child task

Source

pub fn constraint(self, constraint: TaskConstraint) -> Self

Add a temporal constraint

Source

pub fn is_summary(&self) -> bool

Check if this is a summary task (has children)

Source

pub fn remaining_duration(&self) -> Duration

Calculate remaining duration based on completion percentage. Uses linear interpolation: remaining = original × (1 - complete/100)

Source

pub fn effective_percent_complete(&self) -> u8

Get effective completion percentage as u8 (0-100). Returns 0 if not set, clamped to 0-100 range.

Source

pub fn derived_status(&self) -> TaskStatus

Derive task status from actual dates and completion. Returns explicit status if set, otherwise derives from data. For containers, uses effective_progress() to derive status from children.

Source

pub fn complete(self, pct: f32) -> Self

Set the completion percentage (builder pattern)

Source

pub fn is_container(&self) -> bool

Check if this task is a container (has children)

Source

pub fn container_progress(&self) -> Option<u8>

Calculate container progress as weighted average of children by duration. Returns None if not a container or if no children have duration. Formula: Σ(child.percent_complete × child.duration) / Σ(child.duration)

Source

pub fn effective_progress(&self) -> u8

Get the effective progress for this task, considering container rollup. For containers: returns derived progress from children (unless manually overridden). For leaf tasks: returns the explicit completion percentage.

Source

pub fn progress_mismatch(&self, threshold: u8) -> Option<(u8, u8)>

Check if container progress significantly differs from manual override. Returns Some((manual, derived)) if mismatch > threshold, None otherwise.

Source

pub fn actual_start(self, date: NaiveDate) -> Self

Set the actual start date (builder pattern)

Source

pub fn actual_finish(self, date: NaiveDate) -> Self

Set the actual finish date (builder pattern)

Source

pub fn explicit_remaining(self, remaining: Duration) -> Self

Set explicit remaining duration (builder pattern) When set, this overrides the linear calculation duration * (1 - complete/100)

Source

pub fn with_status(self, status: TaskStatus) -> Self

Set the task status (builder pattern)

Trait Implementations§

Source§

impl Clone for Task

Source§

fn clone(&self) -> Task

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Task

Source§

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

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

impl<'de> Deserialize<'de> for Task

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 Task

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§

§

impl Freeze for Task

§

impl RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl UnwindSafe for Task

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,