Implement HandlerResult trait to eliminate unnecessary trailing Flow::Continue #39
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
This PR implements the HandlerResult trait as suggested in issue #4, eliminating the need for unnecessary trailing
Flow::Continuereturns in handlers.Problem
Currently, every handler must return
Try<Output = ()>, which requires explicitFlow::Continuereturns even when handlers just perform some action and want to continue:Solution
The new
HandlerResulttrait allows handlers to return either()(implyingFlow::Continue) or explicitFlow/Trytypes:Implementation Details
HandlerResulttrait: Converts various return types toTry<Output = ()>()→Flow::Continue(the main benefit)Flow→Flow(backward compatibility)Try<Output = ()>→ itself (extensibility)Updated trait methods: All
each_*,create_*,update_*, anddelete_*methods now acceptHandlerResultinstead ofTry<Output = ()>Backward compatibility: Existing code with explicit
Flowreturns continues to workBenefits
✅ Eliminates boilerplate: No more unnecessary
Flow::Continuereturns✅ Backward compatible: Existing handlers with explicit
Flowreturns still work✅ Type-safe: Compile-time guarantees about handler return types
✅ Flexible: Supports mixed usage patterns in the same codebase
Test Plan
()and explicitFlowreturns work correctlyExample Usage
The example in
examples/handler_result_demo.rsdemonstrates the improvement:Fixes #4
🤖 Generated with Claude Code