Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Battery Pack logo

What is a Battery Pack?

A battery pack is a curated set of crates arranged around a common theme. There’s one for building CLIs, one for error handling, one for setting up CI, one for embedded development, and more. You install cargo bp and then:

cargo bp ls               # search crates.io for available battery packs
cargo bp add cli          # add CLI libraries to your project
cargo bp add embedded     # pick your HAL, concurrency model, peripherals
cargo bp new cli          # scaffold a new project from a template

The key ideas:

  • You use the real crates directly. Battery packs don’t wrap or re-export anything. cargo bp add cli puts clap and dialoguer in your Cargo.toml — you use their APIs, their docs, their proc macros. A battery pack is just a list of recommendations.
  • Anybody can publish one. A battery pack is itself a crate on crates.io. If you have opinions about what crates people should use for some domain, you can package those opinions and share them.
  • You’re never locked in. You don’t depend on a battery pack at runtime. It’s purely a source of truth for cargo bp to read. If you don’t like one of its choices, swap it out — your code doesn’t know the difference.

What’s next