Changes#

The add, update and remove lists for one kind of record. Each field of SchedulingChanges is a Changes with record and update types for its kind. Build one with Changes::default() and struct update syntax, or with a struct literal.

Declaration#

#[derive(Clone, Debug)]
pub struct Changes<A, U> {
    pub add: Vec<A>,
    pub update: Vec<U>,
    pub remove: Vec<Id>,
}

impl<A, U> Default for Changes<A, U>

A is the record type for new entries and U is the update type for existing ones:

Field of SchedulingChanges A U
tasks TaskData TaskUpdate
links LinkAdd LinkUpdate
resources ResourceData ResourceUpdate
assignments AssignmentData AssignmentUpdate

Fields#

Every entry in these lists is one operation. An operation is named by its field and index, such as tasks.add[0] or links.remove[2]. ApplyReport uses these paths to list accepted and rejected operations.

add#

pub add: Vec<A>

New records to add. Default: empty.

update#

pub update: Vec<U>

Edits to existing records. Each update names its record by id. Default: empty.

remove#

pub remove: Vec<Id>

Ids of records to remove. Default: empty.

SchedulingChanges gives the order in which operations run.

Example#

Add one task and remove another:

use plen_core::{Changes, SchedulingChanges, TaskData};

fn main() {
    let changes = SchedulingChanges {
        tasks: Changes {
            add: vec![TaskData::new("review")],
            remove: vec!["draft".into()],
            ..Default::default()
        },
        ..Default::default()
    };
    println!("{changes:?}");
}