Slot#
One requirement instance on one task: the task, the resources eligible for it, and the assignment that fills it, if any. Create one with Slot::new, or get a list from plen_assign::slots. Slots are the input of Project::suggest_assignments. A slot lists eligible resources only, never skills.
Declaration#
Slot doesn't implement Default. Start from Slot::new and set other fields with struct update syntax.
Constructors#
new#
Creates an empty slot with value: 1.0 and assignment: None.
Parameters
| Name | Type | Description |
|---|---|---|
id |
impl Into<Id> |
Slot id |
task |
impl Into<Id> |
Task the slot belongs to |
allowed |
Vec<Id> |
Eligible resources, in preference order |
Returns the new Slot.
Fields#
| Field | Type | Default via new |
Description |
|---|---|---|---|
id |
Id |
- | Unique among the slots of one call. A new assignment that fills the slot gets this id. Echoed in SuggestStep::slot and in the unfilled and invalid lists of SuggestResult. |
task |
Id |
- | A scheduled leaf task. |
allowed |
Vec<Id> |
- | Eligible resources. The order is the tie-break preference. A duplicate entry counts once. |
value |
f64 |
1.0 |
Units of a new assignment that fills the slot (1 = 100 %). Must be finite and > 0. |
assignment |
Option<Id> |
None |
The active assignment that fills the slot. None = the slot is empty. |
Whether the slot is empty, held by a resource outside allowed, or held by a resource in allowed decides its AssignTarget category.
A filled slot's new assignment takes the slot id. To keep that binding on the next run, set assignment: Some(slot_id).
Accepted values#
Project::suggest_assignments checks the slots in input order and returns Error::Input with one of these paths:
| Path | When |
|---|---|
slots[i].id |
The id repeats another slot's id, or equals an existing assignment id (active or inactive) other than this slot's own assignment |
slots[i].task |
The task is unknown, unscheduled or a summary |
slots[i].allowed[j] |
The resource is unknown |
slots[i].value |
value isn't finite or is <= 0 |
slots[i].assignment |
The assignment is unknown, inactive, on another task, or bound by two slots |
Serialization#
With the serde feature (cargo add plen-core --features serde), Slot implements Serialize only. assignment is omitted when it's None.
Example#
One empty slot on task 1 at half-time that prefers dev2, and one slot already filled by the assignment review.
use ;
For how slots are visited, filled and rebalanced, see Suggesting assignments.
Related#
plen_assign::slots- builds slots from skills and requirementsSuggestOptions- options passed with the slots tosuggest_assignmentsSuggestResult- the proposal returned for a list of slots- Suggesting assignments - shows building slots and passing them to
suggest_assignments - Skills and Requirements - shows generating slots from a worker pool and requirements