LoadProfile#

Per-bucket load and capacity of a set of resources over a date range. Returned by Project::load_profile for the solved baseline, and in ScheduleResult::profile by Project::preview when PreviewOptions::profile is set, for the previewed dates.

Declaration#

#[derive(Clone, Debug, PartialEq)]
pub struct LoadProfile {
    pub basis: Basis,
    pub resources: Vec<ResourceLoad>,
}

With the serde feature, LoadProfile implements Serialize and Deserialize with camelCase field names.

Fields#

Field Type Description
basis Basis The bucket size used for every bucket in the profile. It's the query's basis when one was set, otherwise the basis derived from config.duration_unit.
resources Vec<ResourceLoad> One entry per selected resource, in input order. The query's resources list picks them; when it's None, every resource of the project is here.

The query that controls the range, the resources and the task lists is ProfileQuery.

Example#

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

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let start = DateTime::from_ymd_hm(2026, 8, 10, 8, 0).ok_or("invalid date")?;

    let mut task = TaskData::new("design");
    task.start_date = Some(start);
    task.duration = Some(2.0);

    let data = ProjectData {
        tasks: vec![task],
        resources: vec![ResourceData {
            id: "anna".into(),
            capacity: None,
            calendar_id: None,
        }],
        assignments: vec![AssignmentData {
            id: None,
            task: "design".into(),
            resource: "anna".into(),
            value: 1.5,
            offset: None,
            duration: None,
        }],
        ..Default::default()
    };

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

    let from = DateTime::from_ymd_hm(2026, 8, 10, 0, 0).ok_or("invalid date")?;
    let to = DateTime::from_ymd_hm(2026, 8, 15, 0, 0).ok_or("invalid date")?;
    let profile = project.load_profile(&ProfileQuery::new(from, to).into())?;

    println!("basis: {:?}", profile.basis);
    for resource in &profile.resources {
        for bucket in &resource.buckets {
            println!(
                "{} {}: load {} / capacity {}",
                resource.resource, bucket.start, bucket.load, bucket.capacity
            );
        }
    }
    Ok(())
}