fix regression in aws-smithy-mocks MatchAny mode and add a new repeatedly()...
fix regression in aws-smithy-mocks MatchAny mode and add a new repeatedly() function for infinite sequences (#4136) ## Motivation and Context fixes https://github.com/smithy-lang/smithy-rs/issues/4135 ## Description * **Fixed regression in RuleMode::MatchAny**: Simple rules (created with `.then_output()`, `.then_error()`, etc.) now correctly work repeatedly in `MatchAny` mode, restoring backward compatibility * **Added repeatedly() method**: New API to make the last response in a sequence repeat indefinitely * **Improved times(n) implementation**: Now uses repetition counts instead of cloning generators, improving memory efficiency * **Added type state pattern**: Prevents adding more responses after calling `repeatedly()` * **Added validation**: Better error messages when `times(n)` is misused * **Fixed overflow handling**: Used saturating_add to safely calculate total responses * **Added unit tests**: New tests for simple rules, `repeatedly()`, and regression * **Updated documentation**: Added examples and explanations for the new functionality ## Questions 1. I've added a typestate pattern for `repeatedly()` since adding new outputs to such a rule would never be used/invalid. Not sure if this is worth it or not though. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] For changes to the smithy-rs codegen or runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "client," "server," or both in the `applies_to` key. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
Loading
Please register or sign in to comment