feat: domain-oriented Cargo feature flags#69
Merged
Conversation
Each domain (blocks, events, gas, price, provider, retrieval, transport) is now a Cargo feature. The default build enables all of them, so existing dependants are unaffected, but consumers can now opt out — for example a crate that only needs block-window calculations can depend on semioscan with default-features = false, features = ["blocks"] and pull in nothing else. Feature dependencies mirror real module dependencies (gas enables events, provider enables transport, retrieval enables events and gas, ws enables provider), and alloy-erc20 becomes optional, compiled only for price and retrieval builds.
The README's Feature Flags section listed only `ws`. Describe every domain feature, how they compose, and how to build a slimmed-down dependency with default-features = false.
Contributor
Author
Self-review passPre-commit
No remaining blockers. All three CI feature combos (test/clippy/doc), |
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.
Summary
Splits the crate into per-domain Cargo features so downstream consumers can build only the parts of Semioscan they use.
defaultenables every domain, so existing dependants compile unchanged; a consumer that only needs, say, block-window math can now usedefault-features = false, features = ["blocks"]and pull in nothing else. Closes #21.What's in the diff
Cargo.toml— new[features]block (blocks,events,gas,price,provider,retrieval,transport, plus the existingws);defaultenables all domains.alloy-erc20becomesoptionaland is pulled only byprice/retrieval. Feature-specific examples gainrequired-features.src/lib.rs— module declarations and root re-exports gated with#[cfg(feature = "...")]; new# Feature flagscrate-doc section.src/types/decimal_precision.rs(moved fromsrc/retrieval/) — relocatingDecimalPrecisionintotypesbreaks the only realgas ↔ retrievalmodule cycle, which Cargo features cannot express.semioscan::DecimalPrecisionkeeps the same root path.src/errors/mod.rs— per-domain error submodules andSemioscanErrorvariants gated to their feature;RpcErrorstays always-on.src/tracing/spans.rs,src/cache/block_range.rs,src/scan/logs.rs— domain-specific helpers in always-on core modules gated to their owning feature so a minimal build stays clean under-D warnings.tests/*— feature-specific integration tests carry a#![cfg(feature = "...")]crate attribute.Reviewer: start with
Cargo.toml(the feature graph) andsrc/lib.rs(the gating); the rest follows from those.Acceptance check (from #21)
cargo check --no-default-featuressucceeds (core build: config/errors/types).cargo check --no-default-features --features blockssucceeds.cargo check --no-default-features --features eventssucceeds.cargo check --no-default-features --features gassucceeds.cargo check --no-default-features --features pricesucceeds.cargo check --no-default-features --features retrievalsucceeds.cargo check --all-featuressucceeds.cargo testbehavior intact (504 lib + integration + 97 doctests pass).CLAUDE.md).Note: the issue sketched
price = ["events"], butpricehas nocrate::eventsusage, so per the issue's "feature dependencies reflect real module dependencies" directive it isprice = ["dep:alloy-erc20"].Test plan
cargo test,cargo test --no-default-features,cargo test --all-features— all passcargo clippy -- -D warningsclean for default,--all-features, and--no-default-features, plus each single featurecargo clippy --all-targets --all-features -- -D warningscleancargo fmt --checkcleancargo doc --no-default-features --no-depsand--all-features --no-depsbuild (see self-review note on doc-link warnings)reuse lintcompliant🤖 Generated with Claude Code