Skip to main content

Strut design

Crates

Strut is not just one crate. The strut crate is the entrypoint for most users, but many supporting strut-* crates exist. This is intended for separation of concerns and maintainability.

All Strut-related crates are public, which is only due to the way crates.io works. However, not all crates are intended to be used directly.

  • Public crates such as strut or the component crates are advertised in this documentation.
    • Use them at will, keeping in mind the versioning.
  • Internal crates such as strut-factory are marked as such in their README.
    • Kindly don’t depend on these crates directly, unless you know well what you are doing.

Crate versions

For Strut to work as intended, no more than one version of Strut should be present in the dependency graph. The versions of the strut-* crates are generally kept in lockstep. However, it is still possible to artificially introduce multiple versions into a binary crate.

To stay on the safe side, make sure to:

  • either depend on just the strut entrypoint crate alone,
  • or depend directly on any number of the component crates, but not on the strut crate itself.
Don’t use Strut in public libraries

The title says it all.

If you depend on any Strut crate in a library published to crates.io, sooner or later someone downstream will end up with multiple versions of Strut in their binary crate. The version conflict may work just fine. It may also break the application at compile time. Or, it may also compile and introduce unexpected hidden behavior.

As the crates.io usage policy states, the whole thing only works effectively if users are able to work together as part of a community in good faith. Kindly don’t use Strut in public libraries. 🙏🏻

Customization

As with any Rust library, there are two layers of customizing Strut: