LinkAdd#
A new dependency between two tasks, added to a live project through SchedulingChanges::links.add. It has the same fields as LinkData, except that id is optional. Build one with a struct literal. LinkAdd has no constructor and no Default, so every field is set.
Declaration#
Fields#
| Field | Type | Default | Description |
|---|---|---|---|
id |
Option<Id> |
None |
Id of the new link. None lets the engine generate one. |
source |
Id |
required | Id of the predecessor task. |
target |
Id |
required | Id of the successor task. |
link_type |
LinkType |
required | Which end of source drives which end of target. |
lag |
f64 |
required | Working time between the two ends, in lag_unit. Must be finite. |
lag_unit |
Option<TimeUnit> |
None |
Unit of lag. None uses config.duration_unit. |
source, target, link_type, lag and lag_unit mean the same as on LinkData, including what happens when an endpoint names no task.
id#
pub id:
Some(id) stores the link under that id. It must not repeat the id of a link already in the project.
None makes the engine pick the first free id of the form $generated_link_1, $generated_link_2, and so on. The generated id is listed in ChangeEffects::generated_links of the ApplyReport, so you can store it for later updates or removals.
Errors#
A LinkAdd is one operation, named links.add[i]. It's rejected, and listed as a RejectedOperation in ApplyReport::rejected instead of applied, when:
idisSomeand a link with that id already exists:duplicate link idlagisNaNor infinite:lag must be finite
An endpoint that names no task, or names an unscheduled task, doesn't reject the operation; see ChangeEffects::dropped_links.
A LinkAdd can reuse the id of a link removed in the same change set; see operation order.
Example#
Link task 1 to task 2 in a solved project, and read back the generated link id:
use ;
For the full edit cycle, see Editing a project.
Related#
LinkData- the full link record with the same fieldsLinkUpdate- edits a link that already existsChangeEffects- reports generated and dropped link ids- Links, constraints and summaries - explains how links drive dates