Subtree#

The scope of a scoped run. Set it as subtree in SolveOptions or PreviewOptions to reschedule one task's branch instead of the whole project. It mirrors gantt's autoSchedule(id, inclusive). Create it with Subtree::new, or as a struct literal to set inclusive yourself.

Declaration#

#[derive(Clone, Debug, PartialEq)]
pub struct Subtree {
    pub task: Id,
    pub inclusive: bool,
}

Subtree has no Default.

Fields#

Field Type Default Description
task Id - Root task of the scope. The scope covers this task, its ancestors and descendants, and every task reached from them through outgoing links, transitively. Each task reached the same way brings its own ancestors and descendants.
inclusive bool true with Subtree::new true also follows incoming links, so the scope includes the root's predecessors and their branches. false follows outgoing links only.

Associated functions#

new#

pub fn new(task: impl Into<Id>) -> Subtree

Creates a scope rooted at task with inclusive: true.

Parameters

Name Type Description
task impl Into<Id> Root task ID. Accepts String, &str, f64 and i32.

Returns - a Subtree with inclusive set to true.

Errors#

A task that is unknown or not scheduled makes the call that receives the options fail with Error::Input. The InputError has kind Validation and path subtree.task.

Example#

use std::sync::Arc;
use plen_core::{Error, Project, ScheduleResult, SolveOptions, Subtree};

// `project` already holds solved data with a task "2".
fn reschedule_branch(project: &mut Project) -> Result<Arc<ScheduleResult>, Error> {
    let options = SolveOptions {
        subtree: Some(Subtree {
            task: "2".into(),
            inclusive: false,
        }),
        ..Default::default()
    };
    project.solve(None, &options)
}