Improve WireframeProtocol docs and fragment tests header#452
Conversation
Added detailed comments to `WireframeApp::with_protocol` and the `WireframeProtocol` trait explaining that currently `ProtocolError` must be `()`. This ensures a uniform interface for dynamic dispatch and prevents leaking application-specific errors. Also added unit test module documentation for fragmentation and reassembly. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideImproves internal documentation around WireframeProtocol error type constraints and clarifies the scope of fragmentation/reassembly tests, without changing runtime behavior. Class diagram for WireframeProtocol and WireframeApp with_protocol documentation constraintclassDiagram
class WireframeProtocol {
<<trait>>
+type Frame
+type ProtocolError
+on_connect(ctx: ConnectionContext) void
+before_send_frame(frame: Frame, ctx: ConnectionContext) void
+on_frame(frame: Frame, ctx: ConnectionContext) void
+on_command_complete(ctx: ConnectionContext) void
+handle_error(error: ProtocolError, ctx: ConnectionContext) void
+on_eof(error: EofError, partial_data: bytes, ctx: ConnectionContext) void
}
class WireframeApp {
+builder() WireframeAppBuilder
}
class WireframeAppBuilder {
+with_protocol(protocol: P) WireframeAppBuilder
}
WireframeAppBuilder --> WireframeApp : builds
WireframeAppBuilder ..> WireframeProtocol : with_protocol<P>
note for WireframeProtocol "When installed via WireframeApp.with_protocol, ProtocolError must currently be () for dynamic dispatch and a uniform interface across connections"
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughState that documentation-only changes were applied: add a doc comment to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
In the WireframeProtocol trait example, changed the handle_error function to remove the unused `error` parameter and updated the logging statement accordingly to avoid unused variable warnings and improve clarity. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
|
@coderabbitai Have the following now been resolved? |
This comment was marked as resolved.
This comment was marked as resolved.
* docs(protocol): add docs clarifying that ProtocolError must be () Added detailed comments to `WireframeApp::with_protocol` and the `WireframeProtocol` trait explaining that currently `ProtocolError` must be `()`. This ensures a uniform interface for dynamic dispatch and prevents leaking application-specific errors. Also added unit test module documentation for fragmentation and reassembly. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> * docs(hooks): simplify example by removing unused error variable In the WireframeProtocol trait example, changed the handle_error function to remove the unused `error` parameter and updated the logging statement accordingly to avoid unused variable warnings and improve clarity. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> --------- Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
* docs(migration): add migration guide for v0.1.0 to v0.2.0 - Introduces v0.1.0 to v0.2.0 migration guide detailing breaking changes - Notes removal of deprecated payload() methods in favor of into_payload() - Updates existing docs for minor formatting improvements - Removes deprecated payload accessor methods from PacketParts and FragmentParts These changes improve developer experience by documenting required migration steps and cleaning up deprecated APIs. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> * Split preamble tests into modules Move preamble tests into grouped modules under tests/preamble/\nwith shared helpers to keep file sizes under the limit.\n\nAdd a Makefile typecheck target to match the commit gates. * Refine preamble tests and docs Address review feedback by clarifying the migration guide intro and\nkeeping payload-accessor documentation neutral.\n\nRefactor preamble tests to avoid excessive nesting and add helper\nRustdoc examples for shared test utilities. * Address review fixes and docs updates Propagate response send errors and tidy logging output. Update client builder docs and buffer sizing constant. Refactor extractor errors/docs and server config tests to align with fixture guidance. Refresh migration guide wording and payload accessor example. * Deduplicate lifecycle builder rebuild Reuse a shared helper when changing connection state types. This keeps lifecycle builder reconstruction aligned with the core builder and removes the ad hoc OnceCell instantiation. * test(server/config): improve backoff configuration tests with multiple scenarios Expanded and diversified the backoff configuration tests for WireframeServer to cover multiple edge cases and delay configurations. Added parameterized tests using rstest, verifying initial and max delay clamping, swapping, and defaults for better test coverage and robustness. Also: - Cleaned up unused test utility functions and redundant assertions. - Enhanced diagnostics in test assertions with scenario descriptions. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> * Refine frame handling test fixtures Ensure rstest fixtures avoid clippy lint issues by adding\nexplicit harness assertions and applying rustfmt-friendly layout\nfor test setup helpers. * Refine frame handling test harness Adjust response logging and public doc comments in frame handling,\nand reuse a shared framed harness with client/server endpoints\nfor response tests. Also normalize message docs to use\nOxford -ize spelling. * Refactor frame handling tests Combine send_response_payload cases with a shared harness that\nincludes both client and server framed endpoints, reducing\nduplicate setup while preserving payload assertions. * refactor(tests): simplify codec recovery tests and improve server config tests - Remove unused rstest fixtures in codec recovery tests and initialize variables directly within test functions - Add helper assert_local_addr_matches_listener function in server config tests to reduce duplication - Refactor server config tests to use the new helper for clearer, more concise assertions Additionally: - Fix client codec initialization in frame_handling tests for clarity - Minor wording improvement in migration guide docs Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> * Improve WireframeProtocol docs and fragment tests header (#452) * docs(protocol): add docs clarifying that ProtocolError must be () Added detailed comments to `WireframeApp::with_protocol` and the `WireframeProtocol` trait explaining that currently `ProtocolError` must be `()`. This ensures a uniform interface for dynamic dispatch and prevents leaking application-specific errors. Also added unit test module documentation for fragmentation and reassembly. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> * docs(hooks): simplify example by removing unused error variable In the WireframeProtocol trait example, changed the handle_error function to remove the unused `error` parameter and updated the logging statement accordingly to avoid unused variable warnings and improve clarity. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> --------- Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com> * Fix PR review regressions in response handling Restore non-fatal handling for response fragmentation and codec encoding errors in frame handling so handler payload mistakes do not disconnect healthy client connections. Keep transport failures fatal by propagating non-encoding send errors. Also restore public visibility for MessageRequest.app_data to avoid a breaking API change and remove the panicking rstest fixture pattern in frame-handling tests. * Split codec recovery tests into dedicated module Move recovery tests out of src/codec/recovery.rs into src/codec/recovery/tests.rs so the production module stays under the 400-line file-size limit. Add rstest fixtures for DefaultRecoveryPolicy and CodecErrorContext and reuse them in tests that previously duplicated setup. * Split extractor module and refine frame-handling tests Decompose extractor into a submodule layout by moving concrete extractor implementations into src/extractor/extractors.rs and converting extractor to directory module layout. This keeps src/extractor/mod.rs below the 400-line threshold while preserving the public extractor API via re-exports. Update frame-handling tests to add the required module-level //! docs, introduce an rstest harness fixture, and inject it into both tests to remove duplicated setup. --------- Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Summary
fragment/tests.rsChanges
Documentation
src/hooks.rs: ExpandedWireframeProtocoldocumentation to explain that while a customProtocolErrortype is allowed,WireframeApp::with_protocolcurrently requiresProtocolError = ()to enable dynamic dispatch with a uniform interface across connections. Includes note about potential future relaxation.src/app/builder_protocol.rs: Updatedwith_protocolmethod docs to clearly state the current constraint ofProtocolError = ()and the rationale for keeping the error type uniform and safe for the builder API.src/fragment/tests.rs: Added module-level documentation describing the fragmentation/reassembly test scope and coverage (e.g.,FragmentHeaderaccess,FragmentSeriesordering/validation,Fragmentersplitting and IDs, andReassemblerassembly with limits/expiry).Tests
Test plan
◳ Generated by DevBoxer ◰
ℹ️ Tag @devboxerhub to ask questions and address PR feedback
📎 Task: https://www.devboxer.com/task/96d25cd1-2470-49fd-a839-d9c46ff4608c
📝 Closes #435
Summary by Sourcery
Document current
ProtocolError = ()constraint for pluggable protocols and clarify fragmentation test coverage.Enhancements:
WireframeProtocoldocumentation around use of customProtocolErrorand the currentProtocolError = ()requirement when used withWireframeApp::with_protocol.WireframeApp::with_protocolbuilder docs to explain the rationale for enforcing a unitProtocolErrorfor dynamic dispatch and a uniform interface.fragment/tests.rswithout changing test logic.Documentation: