Our rust toolchain is very different from cargo, and fits into bazel's norms.
Similar to any other language, create a .rs
file, and then create a rust_library/binary
target which lists that file as it's srcs
.
Add the corresponding target to your deps.
Add a dep on @crates//:<crate name>
(for chromeos) or @alchemy-crates//:<crate name>
(for infra).
If the crate doesn't exist, or if the version needs to be updated, then:
Modify the //bazel/Cargo.toml
, then cd to the directory that contains it and run cargo update --workspace
to update the lockfile.
Modify //third_party/rust_crates/projects/.../Cargo.toml
, then run third_party/rust_crates/vendor.py
.