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


# Pause

One split in a task's work: a stretch of elapsed time, measured from the task start, during which the task does no work. A task holds its pauses in [`TaskData::pauses`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/task-data.md#pauses>). Leveling writes them, and you get them back in the task updates of a [`LevelingResult`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/resources/leveling-result.md>). Create one with `Pause::new` or `Pause::leveling`.

## Declaration

```rust
#[derive(Clone, Debug, PartialEq)]
pub struct Pause {
    pub at: f64,
    pub length: f64,
    pub by: Option<PauseSource>,
}
```

With the `serde` feature, `Pause` also implements `Serialize` and `Deserialize`. `by` is left out of the output when it's `None` and is optional on input.

## Fields

| Field | Type | Description |
|---|---|---|
| `at` | `f64` | Where the pause starts: elapsed time after the task start, in the task's `duration_unit`. Must be finite and `>= 0`. |
| `length` | `f64` | How long the pause lasts: elapsed time in the task's `duration_unit`. Must be finite and `> 0`. |
| `by` | `Option<`[`PauseSource`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/pause-source.md>)`>` | Who wrote the pause. The leveler always sets `Some(PauseSource::Leveling)`. Default: `None`. |

`at` and `length` are wall-clock time, not working time: a `day` is 24 hours and an `hour` is 60 minutes. Fractional values are allowed. On use, a pause occupies the whole minutes `[round(at), round(at + length))`. The two ends are rounded, not `at` and `length` separately, so adjacent pauses never overlap after rounding. A pause that rounds to zero length is ignored.

An invalid `at` or `length` fails strict validation at `tasks[i].pauses[j]`; see [`InputError`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/errors/input-error.md>). The rules for the list as a whole (sorted, non-overlapping) and the task kinds that ignore pauses are on [`TaskData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/task-data.md>).

## Associated functions

### Pause::new

```rust
pub fn new(at: f64, length: f64) -> Pause
```

Creates a pause with `by: None`.

| Name | Type | Description |
|---|---|---|
| `at` | `f64` | Pause start, elapsed time from the task start |
| `length` | `f64` | Pause length, elapsed time |

**Returns** a `Pause` with the given `at` and `length`.

### Pause::leveling

```rust
pub fn leveling(at: f64, length: f64) -> Pause
```

Creates a pause the way the leveler writes it: `by: Some(PauseSource::Leveling)`.

| Name | Type | Description |
|---|---|---|
| `at` | `f64` | Pause start, elapsed time from the task start |
| `length` | `f64` | Pause length, elapsed time |

**Returns** a `Pause` with the given `at` and `length` and `by` set to [`PauseSource::Leveling`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/pause-source.md>).

## Example

```rust
use plen_core::{Pause, PauseSource, TaskData};

fn main() {
    // With the default day unit: no work from day 2 to day 3 after the start.
    let mut task = TaskData::new(1);
    task.pauses = vec![Pause::leveling(2.0, 1.0)];

    assert_eq!(task.pauses[0].by, Some(PauseSource::Leveling));
    assert_eq!(Pause::new(2.0, 1.0).by, None);
}
```

## Related

- [`PauseSource`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/pause-source.md>) - records who wrote the pause
- [`TaskData`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/task-data.md>) - holds a task's pauses
- [`Project::level`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/project/project.md#level>) - writes pauses into the project
- [Leveling Resources](<https://docs.dhtmlx.com/planning-engine/rust/resources-and-assignment/leveling-resources.md#delays-and-pauses>) - when leveling splits a task with a pause instead of delaying it
