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


# SkillMatch

One skill condition of a [`Requirement`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/requirement.md>): a skill id, a comparison and a value. A worker satisfies the match when `worker value <op> value` holds. Build one with `SkillMatch::at_least`, `SkillMatch::no_more` or `SkillMatch::equal`, or with a struct literal, and put it in [`Requirement::matches`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/requirement.md>).

## Declaration

```rust
#[derive(Clone, Debug, PartialEq)]
pub struct SkillMatch {
    pub skill: Id,
    pub op: SkillOp,
    pub value: f64,
}
```

## Fields

| Name | Type | Description |
|---|---|---|
| `skill` | [`Id`](<https://docs.dhtmlx.com/planning-engine/rust/api/core/data/id.md>) | Id of the [`Skill`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/skill.md>) to compare. |
| `op` | [`SkillOp`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/skill-op.md>) | The comparison: `>=`, `<=` or `==`, all inclusive. |
| `value` | `f64` | The value the worker's skill value is compared with. Must be finite. |

A worker without the skill has the value `0`. So `SkillMatch::at_least("qa", 1.0)` excludes that worker, and `SkillMatch::no_more("qa", 0.0)` includes it.

A non-finite `value` is reported by [`slots`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/slots.md>) as [`MatchError::Invalid`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/match-error.md>) at `requirements[i].matches[j].value`.

## Associated functions

### at_least

```rust
pub fn at_least(skill: impl Into<Id>, value: f64) -> SkillMatch
```

Creates a match that holds when the worker's skill value is `>= value`.

| Name | Type | Description |
|---|---|---|
| `skill` | `impl Into<Id>` | Skill id. |
| `value` | `f64` | Minimum value, inclusive. |

**Returns** a `SkillMatch` with `op:` [`SkillOp::AtLeast`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/skill-op.md>).

### no_more

```rust
pub fn no_more(skill: impl Into<Id>, value: f64) -> SkillMatch
```

Creates a match that holds when the worker's skill value is `<= value`.

| Name | Type | Description |
|---|---|---|
| `skill` | `impl Into<Id>` | Skill id. |
| `value` | `f64` | Maximum value, inclusive. |

**Returns** a `SkillMatch` with `op: SkillOp::NoMore`.

### equal

```rust
pub fn equal(skill: impl Into<Id>, value: f64) -> SkillMatch
```

Creates a match that holds when the worker's skill value is `== value`.

| Name | Type | Description |
|---|---|---|
| `skill` | `impl Into<Id>` | Skill id. |
| `value` | `f64` | Required value. |

**Returns** a `SkillMatch` with `op: SkillOp::Equal`.

## Example

A requirement for a backend developer with a QA grade of at least 2 who isn't a trainee:

```rust
use plen_assign::{Requirement, SkillMatch, SkillOp};

fn main() {
    let review = Requirement::new(
        "review",
        "C",
        vec![
            SkillMatch::at_least("backend", 1.0),
            SkillMatch::at_least("qa", 2.0),
            SkillMatch::equal("trainee", 0.0),
        ],
    );

    // Same as SkillMatch::no_more("frontend", 1.0)
    let literal = SkillMatch { skill: "frontend".into(), op: SkillOp::NoMore, value: 1.0 };

    println!("{review:?} {literal:?}");
}
```

## Related

- [`Requirement`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/requirement.md>) - holds the matches in its `matches` list
- [`Skill`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/skill.md>) - the worker value a match compares against
- [`SkillOp`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/skill-op.md>) - the comparison in `op`
- [`slots`](<https://docs.dhtmlx.com/planning-engine/rust/api/assign/slots.md>) - evaluates the matches to fill each slot's `allowed` list
- [Skills and Requirements](<https://docs.dhtmlx.com/planning-engine/rust/resources-and-assignment/skills-and-requirements.md>) - shows how to combine skill conditions in a requirement
