RosterAssignment#

One active assignment of the accepted state, reduced to its id, task and resource. You don't build it yourself. It's an entry of Roster::assignments, which Project::roster returns.

Declaration#

#[derive(Clone, Debug, PartialEq)]
pub struct RosterAssignment {
    pub id: Id,
    pub task: Id,
    pub resource: Id,
}

RosterAssignment doesn't implement Default and has no serde support.

Fields#

Field Type Description
id Id Id of the assignment
task Id Task the assignment is on
resource Id Resource the assignment books

The assignment's units, offset and duration aren't included. Read them from the AssignmentData you passed in.

Example#

use plen_core::{
    AssignmentData, DateTime, Project, ProjectData, ProjectOptions, ResourceData,
    SolveOptions, TaskData,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let monday = DateTime::from_ymd_hm(2026, 8, 10, 8, 0).ok_or("invalid date")?;
    let data = ProjectData {
        tasks: vec![TaskData { start_date: Some(monday), duration: Some(2.0), ..TaskData::new(1) }],
        resources: vec![ResourceData { id: "dev1".into(), capacity: None, calendar_id: None }],
        assignments: vec![AssignmentData {
            id: Some("a1".into()),
            task: 1.into(),
            resource: "dev1".into(),
            value: 1.0,
            offset: None,
            duration: None,
        }],
        ..Default::default()
    };

    let mut project = Project::new(ProjectOptions::default());
    project.solve(Some(data), &SolveOptions::default())?;

    for a in &project.roster()?.assignments {
        println!("{:?}: {:?} on {:?}", a.id, a.resource, a.task);
    }
    Ok(())
}
  • Roster - the container that lists these entries
  • Project::roster - returns the roster with these entries
  • AssignmentData - the input record each entry is reduced from
  • Slot - binds to an existing assignment by its id