# Rust (/pipeline-sdk/reference/toolchains/rust)



{/* Generated by docs-site/scripts/generate-dsl-docs.ts — do not edit. */}

## `rust` [#rust]

Namespace for `hm.rust.toolchain()` and `hm.rust.project()`.

### `rust.project()` [#rustproject]

```python
project(*, path='.', version='stable', image=None, components=('clippy', 'rustfmt'), base=None, cache=None) -> RustProject
```

Build a high-level Rust CI DAG.

Installs the toolchain via rustup, warms a dependency cache keyed on
`Cargo.lock`, and returns a `RustProject` whose `.test()`,
`.clippy()`, and `.fmt()` methods build on that warmup step so
dependency compilation is shared.

| Parameter                              | Type                  | Default                 | Description                                              |
| -------------------------------------- | --------------------- | ----------------------- | -------------------------------------------------------- |
| `path`                                 | `str`                 | `'.'`                   | Path to the crate or workspace root.                     |
| `version`                              | `str`                 | `'stable'`              | rustup channel name (`"stable"`) or a pinned version     |
| (`"1.81.0"`).                          |                       |                         |                                                          |
| `image`                                | `str \| None`         | `None`                  | Local-mode Docker base image override.                   |
| `components`                           | `tuple[str, ...]`     | `('clippy', 'rustfmt')` | rustup components to install alongside the toolchain.    |
| Defaults to `("clippy", "rustfmt")`.   |                       |                         |                                                          |
| `base`                                 | `Step \| None`        | `None`                  | Existing `Step` to attach to instead of emitting a fresh |
| apt-base step.                         |                       |                         |                                                          |
| `cache`                                | `CachePolicy \| None` | `None`                  | Override the warmup step's cache policy. Defaults to     |
| `CacheOnChange` keyed on `Cargo.lock`. |                       |                         |                                                          |

**Returns** `RustProject` — A `RustProject` exposing the common CI steps.

**Examples**

```python
>>> import harmont as hm
>>> proj = hm.rust.project()
>>> hm.group([proj.test(), proj.clippy(), proj.fmt()])
```

### `rust.toolchain()` [#rusttoolchain]

```python
toolchain(*, path='.', version='stable', image=None, components=('clippy', 'rustfmt'), base=None) -> RustToolchain
```

Install the Rust toolchain via rustup.

Produces a `RustToolchain` whose `installed` step is the
rustup-install step. Action methods on the toolchain attach leaves
to `installed`. Use `project()` instead when you want a
pre-built warmup step shared across test/clippy/fmt.

| Parameter                                                    | Type              | Default                 | Description                                                |
| ------------------------------------------------------------ | ----------------- | ----------------------- | ---------------------------------------------------------- |
| `path`                                                       | `str`             | `'.'`                   | Path to the crate or workspace root.                       |
| `version`                                                    | `str`             | `'stable'`              | rustup channel name (`"stable"`) or a pinned version       |
| (`"1.81.0"`).                                                |                   |                         |                                                            |
| `image`                                                      | `str \| None`     | `None`                  | Local-mode Docker base image override.                     |
| `components`                                                 | `tuple[str, ...]` | `('clippy', 'rustfmt')` | rustup components to install alongside the toolchain.      |
| Defaults to `("clippy", "rustfmt")`.                         |                   |                         |                                                            |
| `base`                                                       | `Step \| None`    | `None`                  | Existing `Step` to attach the toolchain install to instead |
| of emitting a fresh apt-base step. Use to share one apt-base |                   |                         |                                                            |
| across multiple toolchains.                                  |                   |                         |                                                            |

**Returns** `RustToolchain` — A `RustToolchain` ready for action methods.

**Examples**

```python
>>> import harmont as hm
>>> tc = hm.rust.toolchain(version="1.81.0")
>>> hm.pipeline(tc.test(), tc.clippy())
```

## `RustEntry` [#rustentry]

Namespace for `hm.rust.toolchain()` and `hm.rust.project()`.

### `RustEntry.project()` [#rustentryproject]

```python
project(*, path='.', version='stable', image=None, components=('clippy', 'rustfmt'), base=None, cache=None) -> RustProject
```

Build a high-level Rust CI DAG.

Installs the toolchain via rustup, warms a dependency cache keyed on
`Cargo.lock`, and returns a `RustProject` whose `.test()`,
`.clippy()`, and `.fmt()` methods build on that warmup step so
dependency compilation is shared.

| Parameter                              | Type                  | Default                 | Description                                              |
| -------------------------------------- | --------------------- | ----------------------- | -------------------------------------------------------- |
| `path`                                 | `str`                 | `'.'`                   | Path to the crate or workspace root.                     |
| `version`                              | `str`                 | `'stable'`              | rustup channel name (`"stable"`) or a pinned version     |
| (`"1.81.0"`).                          |                       |                         |                                                          |
| `image`                                | `str \| None`         | `None`                  | Local-mode Docker base image override.                   |
| `components`                           | `tuple[str, ...]`     | `('clippy', 'rustfmt')` | rustup components to install alongside the toolchain.    |
| Defaults to `("clippy", "rustfmt")`.   |                       |                         |                                                          |
| `base`                                 | `Step \| None`        | `None`                  | Existing `Step` to attach to instead of emitting a fresh |
| apt-base step.                         |                       |                         |                                                          |
| `cache`                                | `CachePolicy \| None` | `None`                  | Override the warmup step's cache policy. Defaults to     |
| `CacheOnChange` keyed on `Cargo.lock`. |                       |                         |                                                          |

**Returns** `RustProject` — A `RustProject` exposing the common CI steps.

**Examples**

```python
>>> import harmont as hm
>>> proj = hm.rust.project()
>>> hm.group([proj.test(), proj.clippy(), proj.fmt()])
```

### `RustEntry.toolchain()` [#rustentrytoolchain]

```python
toolchain(*, path='.', version='stable', image=None, components=('clippy', 'rustfmt'), base=None) -> RustToolchain
```

Install the Rust toolchain via rustup.

Produces a `RustToolchain` whose `installed` step is the
rustup-install step. Action methods on the toolchain attach leaves
to `installed`. Use `project()` instead when you want a
pre-built warmup step shared across test/clippy/fmt.

| Parameter                                                    | Type              | Default                 | Description                                                |
| ------------------------------------------------------------ | ----------------- | ----------------------- | ---------------------------------------------------------- |
| `path`                                                       | `str`             | `'.'`                   | Path to the crate or workspace root.                       |
| `version`                                                    | `str`             | `'stable'`              | rustup channel name (`"stable"`) or a pinned version       |
| (`"1.81.0"`).                                                |                   |                         |                                                            |
| `image`                                                      | `str \| None`     | `None`                  | Local-mode Docker base image override.                     |
| `components`                                                 | `tuple[str, ...]` | `('clippy', 'rustfmt')` | rustup components to install alongside the toolchain.      |
| Defaults to `("clippy", "rustfmt")`.                         |                   |                         |                                                            |
| `base`                                                       | `Step \| None`    | `None`                  | Existing `Step` to attach the toolchain install to instead |
| of emitting a fresh apt-base step. Use to share one apt-base |                   |                         |                                                            |
| across multiple toolchains.                                  |                   |                         |                                                            |

**Returns** `RustToolchain` — A `RustToolchain` ready for action methods.

**Examples**

```python
>>> import harmont as hm
>>> tc = hm.rust.toolchain(version="1.81.0")
>>> hm.pipeline(tc.test(), tc.clippy())
```

## `RustProject` [#rustproject-1]

High-level Rust CI DAG — constructed via `hm.rust.project()`.

Wraps a `RustToolchain` and a pre-built warmup step. Action methods
(`test`, `clippy`, `fmt`) attach leaves to the warmup so
dependency compilation is shared across CI actions.

### Fields [#fields]

| Field       | Type            | Default    |
| ----------- | --------------- | ---------- |
| `toolchain` | `RustToolchain` | *required* |
| `warmup`    | `Step`          | *required* |

### `RustProject.clippy()` [#rustprojectclippy]

```python
clippy(*, flags=(), **kw) -> Step
```

| Parameter | Type              | Default | Description |
| --------- | ----------------- | ------- | ----------- |
| `flags`   | `tuple[str, ...]` | `()`    | —           |
| `kw`      | `Any`             | `{}`    | —           |

**Returns** `Step`

### `RustProject.fmt()` [#rustprojectfmt]

```python
fmt(*, flags=(), **kw) -> Step
```

| Parameter | Type              | Default | Description |
| --------- | ----------------- | ------- | ----------- |
| `flags`   | `tuple[str, ...]` | `()`    | —           |
| `kw`      | `Any`             | `{}`    | —           |

**Returns** `Step`

### `RustProject.test()` [#rustprojecttest]

```python
test(*, flags=(), packages=(), **kw) -> Step
```

| Parameter  | Type              | Default | Description |
| ---------- | ----------------- | ------- | ----------- |
| `flags`    | `tuple[str, ...]` | `()`    | —           |
| `packages` | `tuple[str, ...]` | `()`    | —           |
| `kw`       | `Any`             | `{}`    | —           |

**Returns** `Step`

## `RustToolchain` [#rusttoolchain-1]

Rust toolchain install chain — constructed via `hm.rust.toolchain()`.

Holds the install step produced by rustup. Action methods (`build`,
`test`, `clippy`, `fmt`, `doc`) attach leaves to `installed`.

### Fields [#fields-1]

| Field       | Type   | Default    |
| ----------- | ------ | ---------- |
| `path`      | `str`  | *required* |
| `installed` | `Step` | *required* |

### `RustToolchain.build()` [#rusttoolchainbuild]

```python
build(*, release=False, **kw) -> Step
```

| Parameter | Type   | Default | Description |
| --------- | ------ | ------- | ----------- |
| `release` | `bool` | `False` | —           |
| `kw`      | `Any`  | `{}`    | —           |

**Returns** `Step`

### `RustToolchain.clippy()` [#rusttoolchainclippy]

```python
clippy(**kw) -> Step
```

| Parameter | Type  | Default | Description |
| --------- | ----- | ------- | ----------- |
| `kw`      | `Any` | `{}`    | —           |

**Returns** `Step`

### `RustToolchain.doc()` [#rusttoolchaindoc]

```python
doc(**kw) -> Step
```

| Parameter | Type  | Default | Description |
| --------- | ----- | ------- | ----------- |
| `kw`      | `Any` | `{}`    | —           |

**Returns** `Step`

### `RustToolchain.fmt()` [#rusttoolchainfmt]

```python
fmt(**kw) -> Step
```

| Parameter | Type  | Default | Description |
| --------- | ----- | ------- | ----------- |
| `kw`      | `Any` | `{}`    | —           |

**Returns** `Step`

### `RustToolchain.test()` [#rusttoolchaintest]

```python
test(*, release=False, **kw) -> Step
```

| Parameter | Type   | Default | Description |
| --------- | ------ | ------- | ----------- |
| `release` | `bool` | `False` | —           |
| `kw`      | `Any`  | `{}`    | —           |

**Returns** `Step`

### `RustToolchain.warmup()` [#rusttoolchainwarmup]

```python
warmup(**kw) -> Step
```

| Parameter | Type  | Default | Description |
| --------- | ----- | ------- | ----------- |
| `kw`      | `Any` | `{}`    | —           |

**Returns** `Step`
