name: Rust Setup
description: Install the requested Rust toolchain with clippy + rustfmt and the shared build cache.
inputs:
  toolchain:
    description: Rust toolchain to install (e.g. stable, 1.88)
    required: false
    default: stable
  cache-key:
    description: Additional key suffix for the shared rust-cache to partition caches between workflows.
    required: false
    default: default
runs:
  using: composite
  steps:
    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
      with:
        toolchain: ${{ inputs.toolchain }}
        components: clippy, rustfmt
    - name: Shared cargo cache
      uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
      with:
        key: ${{ inputs.cache-key }}-${{ inputs.toolchain }}
