Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / Collectors

Rust build

The Cargo build in the project directory: the crate it declares, the Rust version and edition it asks for, every workspace member, the dependencies each manifest names with where each comes from and whether it is pinned, and the lock file beside them.

Facts keyrust
Versionv1
Scriptrust.py
Timeout30 seconds

Inputs

InputDescriptionDefaultEnvironment
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR
maxMembersMost workspace members to describe. A workspace past this carries the ones its globs resolve first.200GUARDRAIL_INPUT_MAXMEMBERS

A guardrail that declares an input of the same name passes it through, so the guardrail's configuration in buildnote.json is what decides these values.

A guardrail asks for these facts by name, and reads them back the same way:

json
{
  "collect": ["rust"]
}
python
rust = guardrail.facts("rust")

Facts

The document rust collects. A path carrying [] is an entry of the list before it, and one carrying [path] is a key of the object before it.

FactMeaning
directoryThe projectDir input, as the guardrail configured it.
existsWhether that directory is there. Nothing else is collected when it is not.
manifestPath of the primary manifest, relative to projectDir, always Cargo.toml.
sourcesEvery manifest that was read and understood, in the order they were read. A manifest the reader could not handle is in unparsed instead.
declaredThe Rust version the build asks for, or null when it asks for none. rust-toolchain.toml wins over rust-version, because it is what cargo installs rather than the floor the crate compiles at. A rust-version under [workspace.package] is read as the whole workspace's, which is what a member inheriting it with rust-version.workspace = true compiles at.
declared.versionChannel or version exactly as written, such as 1.76, stable or nightly-2026-03-01.
declared.sourceFile declaring it, relative to projectDir.
declared.pinnedWhether it names one exact version rather than a moving channel. stable, beta and nightly are not pinned; 1.76.0 is.
editionThe Rust edition the package declares, such as 2021, or null when it declares none and 2015 is implied. Taken from the root [package], then from [workspace.package] where the workspace declares one for its members to inherit, then from the first member declaring one of its own.
workspaceWhether the manifest declares a [workspace], so a guardrail can tell a single crate from the root of several.
projectsEvery crate in the build: the root package when it is one, followed by every workspace member.
projects[].pathDirectory of the crate, relative to projectDir, . for the project directory itself.
projects[].manifestThat crate's Cargo.toml, relative to projectDir.
projects[].nameName the [package] table declares, or null when it declares none.
dependenciesWhat the manifests declare, split by whether the build asks for it itself.
dependencies.directEvery dependency any manifest declares, in manifest order.
dependencies.direct[].nameCrate name as the manifest keys it. A renamed dependency is keyed by the name the code uses rather than the one it is published under.
dependencies.direct[].versionRequirement exactly as written, such as 1.0.197 or =1.0.197, or null when the dependency comes from a path, a git URL or the workspace.
dependencies.direct[].scopesWhich of dependencies, dev-dependencies, build-dependencies and workspace declare it.
dependencies.direct[].sourceManifest declaring it, relative to projectDir.
dependencies.direct[].pinnedWhether the requirement names one exact version. A bare 1.0 is Cargo's caret requirement and matches any compatible release, so only an = requirement is pinned.
dependencies.direct[].originWhere it comes from: registry, path for a crate in this checkout, git for one fetched from a URL, or workspace when the member inherits the root's.
dependencies.transitiveAlways empty. What Cargo.lock resolves is not read: lockfiles says whether one is committed.
lockfilesEvery lock file committed, relative to projectDir. A library that commits one pins its own build without constraining anything that depends on it.
droppedWorkspace members left out because maxMembers was reached. Above zero means projects and dependencies describe part of the build rather than all of it.
unparsedEvery manifest the reader could not handle, so a guardrail can tell a build that declares nothing from one nobody could read.
unparsed[].pathPath of that manifest, relative to projectDir.
unparsed[].reasonWhat stopped the reader.

A collector that cannot finish prints what it had along with an incomplete key saying why, so the facts below the point it stopped are absent. A check that cares reads incomplete before the rest.

Example facts

The example facts collected by rust collector:

json
{
  "directory": ".",
  "exists": true,
  "manifest": "Cargo.toml",
  "sources": [
    "Cargo.toml"
  ],
  "declared": {
    "version": "1.76",
    "source": "Cargo.toml",
    "pinned": true
  },
  "edition": "2021",
  "workspace": false,
  "projects": [
    {
      "path": ".",
      "manifest": "Cargo.toml",
      "name": "widget"
    }
  ],
  "dependencies": {
    "direct": [
      {
        "name": "serde",
        "version": "1.0.197",
        "scopes": [
          "dependencies"
        ],
        "source": "Cargo.toml",
        "pinned": false,
        "origin": "registry"
      },
      {
        "name": "anyhow",
        "version": "1.0.81",
        "scopes": [
          "dependencies"
        ],
        "source": "Cargo.toml",
        "pinned": false,
        "origin": "registry"
      },
      {
        "name": "clap",
        "version": "=4.5.4",
        "scopes": [
          "dependencies"
        ],
        "source": "Cargo.toml",
        "pinned": true,
        "origin": "registry"
      },
      {
        "name": "queue",
        "version": null,
        "scopes": [
          "dependencies"
        ],
        "source": "Cargo.toml",
        "pinned": false,
        "origin": "path"
      },
      {
        "name": "proptest",
        "version": "1.4.0",
        "scopes": [
          "dev-dependencies"
        ],
        "source": "Cargo.toml",
        "pinned": false,
        "origin": "registry"
      },
      {
        "name": "cc",
        "version": "1.0.94",
        "scopes": [
          "build-dependencies"
        ],
        "source": "Cargo.toml",
        "pinned": false,
        "origin": "registry"
      }
    ],
    "transitive": []
  },
  "lockfiles": [
    "Cargo.lock"
  ],
  "dropped": 0,
  "unparsed": []
}

Collected for

GuardrailCategoryInputs
rust/edition-floorrustprojectDir
rust/lockfile-committedrustprojectDir
rust/no-git-dependenciesrustprojectDir
rust/version-declaredrustprojectDir

All collectors

Buildnote Limited
Registered in England and Wales, Reg: 16140412