Skip to content

anemo: tighten Router builder ordering via typestate#12

Closed
aschran wants to merge 4 commits into
bmwill:mainfrom
MystenLabs:router-typestate
Closed

anemo: tighten Router builder ordering via typestate#12
aschran wants to merge 4 commits into
bmwill:mainfrom
MystenLabs:router-typestate

Conversation

@aschran
Copy link
Copy Markdown
Contributor

@aschran aschran commented Apr 28, 2026

Summary

  • Adds ServicesOpen / ServicesSealed marker types and a typestate parameter to Router (default ServicesOpen, so existing call sites are unaffected).
  • route, add_rpc_service, and merge are now defined on Router<ServicesOpen>. route_layer consumes Router<ServicesOpen> and returns Router<ServicesSealed>; a second route_layer impl on ServicesSealed lets layers stack.
  • Both states implement Service<Request<Bytes>> and Clone, so Network::start and other consumers keep working unchanged.

Test plan

  • cargo check -p anemo
  • cargo nextest run -p anemo (74/74 pass; routing tests rewritten to cover the new shape)
  • cargo test -p anemo --doc
  • cargo clippy --workspace --all-targets
  • cargo fmt --all -- --check

🤖 Generated with Claude Code

semenov-vladyslav and others added 4 commits March 18, 2025 14:19
Move route, add_rpc_service, and merge onto Router<ServicesOpen>;
route_layer transitions to Router<ServicesSealed>, on which only
further route_layer calls are available.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aschran
Copy link
Copy Markdown
Contributor Author

aschran commented Apr 28, 2026

Opened against the wrong repo; recreating on MystenLabs/anemo.

@aschran aschran closed this Apr 28, 2026
@aschran aschran deleted the router-typestate branch April 28, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants