Migrate Rust examples to SDK 0.11.0 service API#407
Merged
Conversation
The Rust SDK 0.11.0 replaces the trait-based service definition with a struct-based one: the macro (#[service]/#[object]/#[workflow]) goes on the struct's impl block, each handler is annotated with #[handler], and shared/exclusive is inferred from the context type. Services are bound with .bind(Struct) instead of .bind(StructImpl.serve()). Updates all examples in rust/basics and both rust/templates. Service and handler names are preserved, so HTTP endpoints and generated clients (e.g. SubscriptionServiceClient) are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
Rust SDK 0.11.0 changes how services are defined. The old trait-based definition is deprecated in favor of a struct-based one:
#[service]/#[object]/#[workflow]macro now goes on the struct'simplblock (no separate trait).#[handler].ObjectContextvsSharedObjectContext,WorkflowContextvsSharedWorkflowContext) — no more#[shared]..bind(Struct)instead of.bind(StructImpl.serve()).Changes
Migrated every Rust example to the new API:
rust/basics—p0_durable_execution,p1_building_blocks,p2_virtual_objects,p3_workflows, andstubsrust/templates/rustrust/templates/rust-shuttleService and handler names are preserved, so HTTP endpoints and generated clients (e.g.
SubscriptionServiceClient) are unchanged.Verification
cargo buildpasses for all three projects (rust/basics --examples,rust/templates/rust,rust/templates/rust-shuttle) againstrestate-sdk = "0.11.0".🤖 Generated with Claude Code