# cargo plugin

## cargo - Automatically stage crate dependencies

A convenience Source element for vendoring rust project dependencies.

Placing this source in the source list, after a source which stages a Cargo.lock file, will allow this source to read the Cargo.lock file and obtain the crates automatically into %{vendordir}.

Set the ref field to an empty list like so: ref: [], and then run bst source track path_to_bst_file.bst.

Usage:

    # Specify the cargo source kind
    kind: cargo

    # Url of the crates repository to download from (default: https://static.crates.io/crates)
    url: https://static.crates.io/crates

    # Internal source reference, this is a list of dictionaries
    # which store the crate names and versions.
    #
    # This will be automatically updated with `bst source track`
    ref:
    - name: packagename
      version: 1.2.1
    - name: packagename
      version: 1.3.0

    # Specify a directory for the vendored crates (defaults to ./crates)
    vendor-dir: crates

    # Optionally specify the name of the lock file to use (defaults to Cargo.lock)
    cargo-lock: Cargo.lock

See built-in functionality doumentation for details on common configuration options for sources.

### Reporting SourceInfo

The cargo source reports the URL of the archive crates as the url for each crate.

Further, the cargo source reports the SourceInfoMedium.REMOTE_FILE medium and the SourceVersionType.SHA256 version_type, for which it reports the checksum of the archive as the version.

The versions extracted from the Cargo.lock at tracking time are used to report the guess_version.

Additional source info can be specified using the provenance field for each referenced crate as per built-in source provenance documentation.