Get Rust Packages
The typical way of getting a Rust package is referencing it in the project dependencies.
Configure connection to the Cargo registry. The instructions are different for a local Cargo registry and for a mirror of a remote registry (the most common case is mirroring crates.io):
In your Rust project, add the
config.toml
file to the.cargo
directory.Add the registry data to the
config.toml
file. For example:[registries.space-registry] index = "sparse+https://cargo.registry.jetbrains.space/mycompany/p/projectkey/myCrates" credential-provider="cargo:token"If you are not sure about the URL, you can copy the URL of a particular container registry on the Packages page.
Log in to the registry:
cargo login --registry=space-registryHere
space-registry
is the registry name you specified inconfig.toml
.When asked for credentials, specify either your Space username and password (we recommend that you use a personal token instead) or a client ID and a client secret of a service account.
In your Rust project, add the
config.toml
file to the.cargo
directory.Add the registry data to the
config.toml
file. For example:[registries.space-registry-mirror] index = "sparse+https://cargo.registry.jetbrains.space/mycompany/p/projectkey/myCrates-mirror" credential-provider="cargo:token"If you are not sure about the URL, you can copy the URL of a particular container registry on the Packages page.
Log in to the registry:
cargo login --registry=space-registry-mirrorHere
space-registry-mirror
is the registry name you specified inconfig.toml
.When asked for credentials, specify either your Space username and password (we recommend that you use a personal token instead) or a client ID and a client secret of a service account.
Open the
config.toml
and configure registry replacing by adding the lines:[source] space-registry-mirror = { registry = "sparse+https://cargo.registry.jetbrains.space/mycompany/p/projectkey/myCrates-mirror" } crates-io = { replace-with = "space-registry-mirror" }
Add the dependency to the project's
Cargo.toml
file. For example:[dependencies] rust-sample-project = { version = "0.1.0", registry = "space-registry" }Here
rust-sample-project
is the package name andspace-registry
is the registry name you specified inconfig.toml
.Note that you can get the exact package reference in Space:
In Space, open the Packages page of the project that provides the required package.
Open the package properties page, copy the reference snippet, and paste it to your
Cargo.toml
.
Build your project with the new dependency:
cargo build