feat(cargo): split entity-attribute generators into opt-out features#132
Merged
Conversation
…ures
Every entity-attribute group now lives behind its own Cargo feature so
users can shrink their build by switching off generators they don't need.
All new features ship default-on, so existing projects compile unchanged.
New features (default-on, non-breaking):
- events — `{Entity}Event` enum, lifecycle event variants
- commands — command structs, dispatcher trait (`#[entity(commands)]`,
`#[command(...)]`)
- hooks — `{Entity}Hooks` trait (manual wiring; #127 tracks
auto-invocation)
- transactions — `{Entity}TransactionRepo` adapter + deprecated `with_*`
builders (`#[entity(transactions)]`)
- aggregate_root — `New{Entity}` constructor and transactional `save()`
(`#[entity(aggregate_root)]`)
- migrations — compile-time `MIGRATION_UP`/`MIGRATION_DOWN` constants
(`#[entity(migrations)]`)
- projections — projection structs + `find_by_id_<projection>` methods
(`#[projection(...)]`)
Plumbing:
- Each feature in `entity-derive` activates its sibling in
`entity-derive-impl`. The facade now declares
`entity-derive-impl = { … default-features = false }` so transitive
default-on doesn't leak past the user's explicit selection.
- In `entity-derive-impl/src/entity.rs`, every gated submodule and its
`generate(&entity)` call sits under `#[cfg(feature = "<name>")]`.
- New helper `guard_disabled_attribute()` emits a friendly
`compile_error!` if the entity attribute is present but the feature is
off — much clearer than a missing-method puzzle at the call site.
- `streams` now depends on `events` (the NOTIFY payload is an event
variant; `streams` without `events` would not link).
- Crate-level `#![cfg_attr(any(not(feature = "migrations"), not(feature
= "projections")), allow(dead_code, unused_imports))]` keeps minimal
builds warning-free without touching individual parser helpers.
README feature matrix rewritten with a Default column and a "If you use
an entity attribute whose feature is disabled, the macro tells you so"
note plus a `default-features = false` example.
Bump:
- entity-derive-impl: 0.6.2 -> 0.6.3
- entity-derive: 0.8.3 -> 0.8.4
`entity-core` is unchanged.
Closes #131
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #131
Summary
Every `#[entity(...)]` attribute group now sits behind a Cargo feature flag. All new features ship default-on, so existing builds compile unchanged. Users who want lean builds opt out with `default-features = false` and pick what they need.
New features (default-on)
Plumbing
README
The feature matrix is rewritten with a Default column, the new features documented, an example for `default-features = false`, and a note about the `compile_error!` guard.
Version bump
`entity-core` is unchanged.
Test plan
Backward compatibility
All new features are default-on. No source change required for existing users. Anyone setting `default-features = false` and forgetting a feature gets a precise `compile_error!` at the offending attribute.