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


# GapBehavior

Selects how auto-scheduled tasks are placed relative to their links: kept at their current (preferred) dates where the links allow it, or pulled to the earliest position. It's the type of [`SchedulingConfig::gap_behavior`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/scheduling-config.md#gap_behavior>), where the default is `GapBehavior::Preserve`.

## Declaration

```rust
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GapBehavior {
    Preserve,
    Compress,
}
```

With the `serde` feature, the enum implements `Serialize` and `Deserialize` and uses the lowercase spellings `"preserve"` and `"compress"`.

## Variants

| Variant | Description |
|---|---|
| `Preserve` | A task keeps its current dates unless a link or constraint pushes it. Gaps between linked tasks stay as they are. |
| `Compress` | Every auto-scheduled task moves to the earliest position its links and constraints allow, closing gaps. Summaries don't move as blocks: their links apply to the leaf tasks, as with `move_projects: false`. |

## Example

```rust
use plen_core::{GapBehavior, SchedulingConfig};

fn main() {
    let config = SchedulingConfig {
        gap_behavior: GapBehavior::Compress,
        ..Default::default()
    };
    assert_eq!(config.gap_behavior, GapBehavior::Compress);
    assert_eq!(SchedulingConfig::default().gap_behavior, GapBehavior::Preserve);
}
```

## Related

- [`SchedulingConfig`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/scheduling-config.md>) - the config field that sets the behavior
- [`LinkData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/link-data.md>) - the links that push or pull tasks under each behavior
- [Links, constraints and summaries](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/links-constraints-summaries.md>) - how preserve and compress place linked tasks
- [Scheduling a Project](<https://docs.dhtmlx.com/planning-engine/rust/scheduling/scheduling-a-project.md>) - how `project_start` interacts with each behavior
