The rust plugin

The rust plugin is useful for building Rust-based parts using the Cargo package manager to drive the build.

This plugin uses the common plugin keywords as well as those for “sources”. For more information, see Snapcraft parts metadata.

Additional features and syntax are dependent on which base is being used, as outlined below:

See Rust applications for a simple example, or search GitHub for projects already using the plugin.

This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.

base: core20

If a rust-toolchain file is detected, the toolchain it specifies will be used by default otherwise the latest stable toolchain will be used.

  • rust-features (list of strings)
    Features used to build optional dependencies
  • rust-path (list of strings)
    Defaults to the current working directory. Can be set to the relative path for the crate to build when using workspaces. Only one item is currently supported.

Requires Snapcraft version 4.0+.

base: core18 | core

  • rust-channel (string)
    Used to select which rust channel (stable, beta, nightly)
  • rust-features (list of strings)
    Features used to build optional dependencies
  • rust-revision (string)
    Used to select which rust version

If a rust-toolchain file is detected, the toolchain it specifies will be used by default. However, if rust-channel or rust-revision are set, the rust-toolchain file will be overridden.

If neither a rust-toolchain exists nor rust-channel or rust-revision are set, the latest stable toolchain will be used.

Requires Snapcraft version 3.x.

Last updated 4 months ago. Help improve this document in the forum.