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
strutor the component crates are advertised in this documentation.- Use them at will, keeping in mind the versioning.
- Internal crates such as
strut-factoryare marked as such in theirREADME.- 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
strutentrypoint crate alone, - or depend directly on any number of the component crates, but not on the
strutcrate itself.
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:
- At compile time the Cargo features affect what parts of Strut are pulled in.
- Features are grouped by Strut component and are described in the component documentation.
- As a design choice, the special
defaultfeature is always empty in all Strut crates.
- At runtime, the included features are customized via external configuration.