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::Continue
returns in handlers.Problem
Currently, every handler must return
Try<Output = ()>
, which requires explicitFlow::Continue
returns even when handlers just perform some action and want to continue:Solution
The new
HandlerResult
trait allows handlers to return either()
(implyingFlow::Continue
) or explicitFlow
/Try
types:Implementation Details
HandlerResult
trait: 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 acceptHandlerResult
instead ofTry<Output = ()>
Backward compatibility: Existing code with explicit
Flow
returns continues to workBenefits
✅ Eliminates boilerplate: No more unnecessary
Flow::Continue
returns✅ Backward compatible: Existing handlers with explicit
Flow
returns still work✅ Type-safe: Compile-time guarantees about handler return types
✅ Flexible: Supports mixed usage patterns in the same codebase
Test Plan
()
and explicitFlow
returns work correctlyExample Usage
The example in
examples/handler_result_demo.rs
demonstrates the improvement:Fixes #4
🤖 Generated with Claude Code