[Canonical page](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/changes/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# Changes

The add, update and remove lists for one kind of record. Each field of [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/scheduling-changes.md>) 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

```rust
#[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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/task-data.md>) | [`TaskUpdate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/task-update.md>) |
| `links` | [`LinkAdd`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/link-add.md>) | [`LinkUpdate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/link-update.md>) |
| `resources` | [`ResourceData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/resource-data.md>) | [`ResourceUpdate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/resource-update.md>) |
| `assignments` | [`AssignmentData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/assignment-data.md>) | [`AssignmentUpdate`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/assignment-update.md>) |

## 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`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/apply-report.md>) uses these paths to list accepted and rejected operations.

### add

```rust
pub add: Vec<A>
```

New records to add. Default: empty.

### update

```rust
pub update: Vec<U>
```

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

### remove

```rust
pub remove: Vec<Id>
```

[`Id`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/id.md>)s of records to remove. Default: empty.

[`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/scheduling-changes.md#operation-order>) gives the order in which operations run.

## Example

Add one task and remove another:

```rust
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:?}");
}
```

## Related

- [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/scheduling-changes.md>) - holds one `Changes` per record kind
- [`ApplyReport`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/apply-report.md>) - reports each operation by its path
- [`RejectedOperation`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/changes/rejected-operation.md>) - names a refused entry of these lists
- [Data Updates](<https://docs.dhtmlx.com/planning-engine/rust/live-projects/editing-a-project.md>) - shows how to build change sets
