Rust

Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.

cargoPackageAddress()

cargoPackageAddress(handle)

Undocumented.

declared_path()

declared_path(handle, path = ".")

Undocumented.

normalize_deps()

normalize_deps(deps)

Undocumented.

cargoPackageActionHandle

const cargoPackageActionHandle

Undocumented.

cargoPackageOutputSlug()

cargoPackageOutputSlug(handle)

Undocumented.

cargoPackageHandles()

cargoPackageHandles()

Undocumented.

rust_file_sources

const rust_file_sources

Undocumented.

sources

const sources

Undocumented.

resources

const resources

Undocumented.

testResources

const testResources

Undocumented.

rust_toolchain_version()

rust_toolchain_version(handle)

Undocumented.

cargoScriptPreamble()

cargoScriptPreamble(scriptPreamble = "")

Undocumented.

cargoRemapFlag()

cargoRemapFlag(kacheActive)

Undocumented.

cargoInvocationScript()

cargoInvocationScript(cargoCommand, opts = {})

Undocumented.

rustToolEnv()

rustToolEnv(toolSpec, kacheActive)

Undocumented.

cargoBuild

const cargoBuild

Undocumented.

cargoDistPackage

const cargoDistPackage

Undocumented.

parseDocTestOutput()

parseDocTestOutput(stderr)

Undocumented.

cargoTest

const cargoTest

Run a Cargo binary crate's doc-tests. //rules/rust/test.js discovers and runs every unit/integration test binary beneath the package label via cargo test --no-run; running the whole crate's tests again here would duplicate that work. Doc-tests aren't discoverable via --no-run though (they only ever run through a real cargo test), so this stays scoped to --doc as the one piece the fan-out can't cover. A workspaceMember crate's doc-tests run as one shared, memoized cargo test --doc --workspace invocation per real workspace root (see runWorkspaceDocTests above), attributed back to this one crate by name — same reasoning and precedent as cargoClippy/runWorkspaceClippy (rules/rust/lint.js). A standalone crate has no workspace to share a run with, so it keeps the simple per-crate cargo test --doc invocation.

ParameterTypeDescription
handleobjectTarget handle returned by cargoPackage().

Returns: Promise<object> Run result from cargo test --doc.

cargoPackage

const cargoPackage

Declare a Cargo package target: a self-contained crate, a cargo workspace root (member manifests are globbed via **\/Cargo.toml), or one member of an outer workspace declared elsewhere (see workspaceMember). bin is optional — a lib-only package is a fully valid target for fmt/test, just not for build/package. even when the workspace opt mode is debug. setting for this package. a cargo workspace rooted in an ancestor directory (not this one) — build/ test/fmt sandbox inputs glob from the repo root instead of just path, so cargo can resolve the enclosing [workspace] and any path-deps on sibling members. Leave false for a self-contained crate or a workspace root itself.

ParameterTypeDescription
optsobject
[opts.path="."]stringWorkspace-relative directory containing Cargo.toml.
[opts.bin]stringstring[]
[opts.release=false]booleanAlways build with cargo build --release,
[opts.toolchain]objectstring
[opts.cargoArgs=[]]string[]Extra arguments appended to cargo build.
[opts.testArgs=[]]string[]Extra arguments appended to cargo test.
[opts.testTools=[]]ArraynativeTool() specifications exposed on PATH while running cargo test.
[opts.deps=[]]ArrayExtra deps, e.g. a resourcePackage() (see //rules/asset) providing non-.rs files an include_str!/include_bytes! needs.
[opts.testDeps=[]]ArrayresourcePackage() deps the test binaries read at runtime but the crate doesn't compile against — materialized into the test sandbox only, so changing them re-runs tests without invalidating the build.
[opts.doctest]booleanOverride the workspace rustConfig.doctest
[opts.workspaceMember=false]booleanThis package is a member of

Returns: object Exported label handle.