Skip to content

Unify app constructors with generic new#254

Merged
leynos merged 4 commits intomainfrom
codex/merge-and-refactor-new-constructors
Aug 4, 2025
Merged

Unify app constructors with generic new#254
leynos merged 4 commits intomainfrom
codex/merge-and-refactor-new-constructors

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Aug 3, 2025

Summary

  • merge WireframeApp::new and new_with_envelope into one generic new
  • deprecate new_with_envelope as a wrapper around new
  • update docs, examples, and tests to use the generic constructor

Testing

  • make fmt
  • make lint
  • make test
  • make nixie (fails: error: too many arguments. Expected 0 arguments but got 1)

https://chatgpt.com/codex/tasks/task_e_688fd388dc08832299c95dd15ab3a723

Summary by Sourcery

Consolidate application constructors by introducing a generic new method parameterized by an envelope type, deprecating new_with_envelope, and propagate the change across docs, tests, and examples.

Enhancements:

  • Merge WireframeApp::new and new_with_envelope into a single generic new method
  • Deprecate new_with_envelope in favor of the unified generic constructor

Documentation:

  • Update README, inline docs, and examples to call the unified new method

Tests:

  • Refactor tests to replace new_with_envelope calls with new using explicit envelope types

Chores:

  • Standardize multi-line block formatting for small method definitions

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Aug 3, 2025

Reviewer's Guide

This PR unifies the application constructors by replacing new_with_envelope with a single generic new method, deprecates the old wrapper, updates all tests, examples, and documentation to use the new API, and applies consistent block-style formatting to single-expression functions.

Class diagram for Envelope and Packet trait updates

classDiagram
    class Envelope {
        +id: u32
        +msg: Vec<u8>
        +new(id: u32, msg: Vec<u8>) Self
        +into_parts(self) (u32, Vec<u8>)
    }
    class Packet {
        <<interface>>
        +id() u32
        +into_parts(self) (u32, Vec<u8>)
        +from_parts(id: u32, msg: Vec<u8>) Self
    }
    Envelope ..|> Packet
Loading

File-Level Changes

Change Details Files
Merge new and new_with_envelope into a single generic constructor
  • Remove specialized WireframeApp::new() impl for Envelope
  • Add generic impl<E: Packet> with pub fn new() -> Result<Self>
  • Mark new_with_envelope as deprecated and delegate to new()
  • Include inline examples in doc comments for using new
src/app.rs
Update tests, examples, and README to use the unified new() API
  • Replace all new_with_envelope() calls with new() (adding explicit type parameters where needed)
  • Adjust closure signatures to annotate envelope types in examples
  • Modify README and documentation snippets to reflect WireframeApp::<_,_,MyEnv>::new()
tests/
examples/
README.md
Apply consistent block-style formatting to single-expression functions
  • Expand one-liner methods and trait impls (e.g., fn id(&self) -> u32 { self.id }) into multiline blocks
  • Add braces and newlines around single-statement closures and functions
  • Standardize formatting in error conversions and protocol hooks
src/app.rs
tests/
examples/

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 3, 2025

Summary by CodeRabbit

  • Documentation
    • Updated usage instructions and examples to reflect changes in how custom envelope types are used with the app, replacing references to the deprecated method with the new approach.
  • New Features
    • Added support for creating app instances with custom envelope types via a new constructor method.
  • Deprecation
    • Introduced a deprecated method for backwards compatibility, advising users to transition to the new constructor.
  • Tests
    • Updated test cases to use the new constructor and explicit type parameters for clarity and consistency.

Walkthrough

Update the API for WireframeApp to use a generic new() constructor when specifying a custom envelope type implementing Packet, deprecating the former new_with_envelope() method. Revise documentation, examples, and tests to reflect this change. Reformat several function bodies for clarity and add explicit type annotations in closures and instantiations.

Changes

Cohort / File(s) Change Summary
Documentation and Examples Update
README.md, examples/echo.rs, examples/metadata_routing.rs, examples/ping_pong.rs
Update usage instructions and example code to use WireframeApp::<_, _, MyEnv>::new() instead of .new_with_envelope(). Add explicit type annotations and adjust import formatting.
API and Implementation Generalisation
src/app.rs
Generalise WireframeApp constructor to accept a generic envelope type implementing Packet. Add a generic new() method, deprecate new_with_envelope(), and reformat several function bodies for clarity.
Test Suite Refactor
tests/lifecycle.rs, tests/response.rs, tests/routes.rs, tests/wireframe_protocol.rs
Replace .new_with_envelope() with .new() in test setup. Add explicit type parameters. Reformat trait implementations for clarity. Consolidate imports. No changes to test logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WireframeApp
    participant Envelope (custom)
    User->>WireframeApp: WireframeApp::<_, _, MyEnv>::new()
    WireframeApp->>Envelope: Use MyEnv (implements Packet)
    WireframeApp-->>User: App instance (with custom envelope)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

Out with the old, in with the new,
A single new()—no more to do!
Generics now reign, envelopes in tow,
Deprecation whispers, “Let the old ways go.”
Tests and docs align, type clarity in sight,
Wireframe marches on—API shining bright!
🚀✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ad21d8 and f7b5fe1.

📒 Files selected for processing (3)
  • src/app.rs (1 hunks)
  • tests/routes.rs (2 hunks)
  • tests/wireframe_protocol.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Function documentation must include clear examples demonstrating the usage and outcome of the function. Test documentation should omit examples where the example serves only to reiterate the test logic.
No single code file may be longer than 400 lines. Long switch statements or dispatch tables should be broken up by feature and constituents colocated with targets. Large blocks of test data should be moved to external data files.
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//! ) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums. Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status....

Files:

  • tests/wireframe_protocol.rs
  • tests/routes.rs
  • src/app.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • tests/wireframe_protocol.rs
  • tests/routes.rs
  • src/app.rs
🧬 Code Graph Analysis (2)
tests/wireframe_protocol.rs (1)
src/app.rs (2)
  • new (201-201)
  • new (280-280)
tests/routes.rs (1)
src/app.rs (2)
  • new (201-201)
  • new (280-280)
🔇 Additional comments (8)
tests/wireframe_protocol.rs (3)

19-19: LGTM: Import consolidation follows standard practices.

The consolidated import statement is clean and follows Rust conventions.


54-54: Correct usage of the new generic constructor.

The explicit type parameters properly specify the envelope type, aligning with the unified API design.


78-78: Consistent application of the new constructor pattern.

Both test functions correctly use the new generic constructor syntax.

tests/routes.rs (2)

43-43: Proper usage of the unified constructor API.

The explicit type parameter correctly specifies the TestEnvelope type, demonstrating the new generic approach.


82-82: Consistent application across test functions.

Both test functions correctly adopt the new constructor pattern with explicit envelope typing.

src/app.rs (3)

250-253: Well-designed generic implementation.

The impl block properly generalizes the envelope type with appropriate Packet trait bounds, enabling type-safe usage with custom envelope types.


258-280: Excellent documentation with practical examples.

The comprehensive documentation includes clear error information and a complete example demonstrating custom envelope implementation. This follows the coding guideline requiring clear examples for function documentation.


284-293: Proper deprecation strategy maintains backward compatibility.

The deprecated method provides clear migration guidance whilst preserving existing functionality. The deprecation note specifically instructs users on the new syntax.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/merge-and-refactor-new-constructors

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 4, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 4, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e085c92 and a14d256.

📒 Files selected for processing (9)
  • README.md (2 hunks)
  • examples/echo.rs (2 hunks)
  • examples/metadata_routing.rs (2 hunks)
  • examples/ping_pong.rs (1 hunks)
  • src/app.rs (3 hunks)
  • tests/lifecycle.rs (4 hunks)
  • tests/response.rs (4 hunks)
  • tests/routes.rs (3 hunks)
  • tests/wireframe_protocol.rs (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • tests/wireframe_protocol.rs
  • examples/metadata_routing.rs
  • tests/response.rs
  • examples/ping_pong.rs
  • examples/echo.rs
  • tests/routes.rs
  • tests/lifecycle.rs
  • src/app.rs
**/*.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
  • Code blocks should be wrapped to 120 columns.
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • README.md
🧬 Code Graph Analysis (4)
tests/wireframe_protocol.rs (2)
src/hooks.rs (2)
  • before_send (32-32)
  • before_send (101-105)
src/app.rs (2)
  • new (203-205)
  • new (290-292)
examples/echo.rs (1)
src/app.rs (2)
  • new (203-205)
  • new (290-292)
tests/routes.rs (2)
tests/lifecycle.rs (3)
  • id (109-111)
  • into_parts (113-115)
  • from_parts (117-119)
src/app.rs (9)
  • id (181-181)
  • id (215-217)
  • into_parts (184-184)
  • into_parts (209-211)
  • into_parts (219-221)
  • from_parts (187-187)
  • from_parts (223-225)
  • new (203-205)
  • new (290-292)
tests/lifecycle.rs (2)
src/app.rs (9)
  • new (203-205)
  • new (290-292)
  • id (181-181)
  • id (215-217)
  • into_parts (184-184)
  • into_parts (209-211)
  • into_parts (219-221)
  • from_parts (187-187)
  • from_parts (223-225)
tests/routes.rs (3)
  • id (28-30)
  • into_parts (32-34)
  • from_parts (36-38)
🪛 GitHub Actions: CI
tests/wireframe_protocol.rs

[warning] 14-34: Prettier formatting check failed. Code style differences detected; import statements and function bodies should be formatted consistently as single lines or multiline.

tests/routes.rs

[warning] 25-25: Prettier formatting check failed. Code style differences detected; function implementations should be formatted as single lines.

tests/lifecycle.rs

[warning] 106-106: Prettier formatting check failed. Code style differences detected; function implementations should be formatted as single lines.

src/app.rs

[warning] 140-140: Prettier formatting check failed. Code style differences detected; lines should be formatted to a single line instead of multiple lines.


[warning] 200-200: Prettier formatting check failed. Code style differences detected; lines should be formatted to a single line instead of multiple lines.


[warning] 209-209: Prettier formatting check failed. Code style differences detected; lines should be formatted to a single line instead of multiple lines.


[warning] 215-215: Prettier formatting check failed. Code style differences detected; lines should be formatted to a single line instead of multiple lines.


[warning] 276-284: Prettier formatting check failed. Code style differences detected; multiline struct and function definitions should be formatted as single lines or vice versa.


[warning] 301-301: Prettier formatting check failed. Code style differences detected; function body should be formatted as a single line.

🪛 GitHub Check: build-test
src/app.rs

[warning] 215-215:
Diff in /home/runner/work/wireframe/wireframe/src/app.rs


[warning] 209-209:
Diff in /home/runner/work/wireframe/wireframe/src/app.rs


[warning] 301-301:
Diff in /home/runner/work/wireframe/wireframe/src/app.rs


[warning] 284-284:
Diff in /home/runner/work/wireframe/wireframe/src/app.rs


[warning] 276-276:
Diff in /home/runner/work/wireframe/wireframe/src/app.rs

🔇 Additional comments (15)
examples/ping_pong.rs (1)

133-133: LGTM! Explicit type annotation improves clarity.

The change from |_| to |_: &Envelope| makes the closure signature explicit and aligns with the consistent pattern applied across other examples.

examples/metadata_routing.rs (1)

70-70: LGTM! Explicit envelope type annotations enhance clarity.

The addition of explicit &Envelope type annotations to the closure parameters improves code readability and maintains consistency with similar changes across other examples.

Also applies to: 79-79

examples/echo.rs (2)

8-11: LGTM! Import formatting and envelope type addition support the API update.

The multiline import format and explicit Envelope import align with the unified generic constructor approach.


20-20: LGTM! Explicit envelope type annotation improves consistency.

The change from _ to _: &Envelope follows the pattern established across other examples and enhances type clarity.

tests/lifecycle.rs (2)

52-52: LGTM! Constructor change aligns with unified API.

The replacement of new_with_envelope() with the generic new() constructor follows the deprecation plan outlined in the PR objectives.


77-77: LGTM! Explicit generic parameters improve type clarity.

The explicit WireframeApp::<_, _, Envelope>::new() syntax clearly specifies the envelope type and aligns with the new generic constructor approach.

Also applies to: 92-92

tests/wireframe_protocol.rs (2)

53-53: LGTM! Explicit generic parameters align with unified API.

The explicit WireframeApp::<_, _, Envelope>::new() syntax correctly uses the new generic constructor approach and improves type clarity.

Also applies to: 77-77


37-39: Revert to single-line function formatting.

The coding guidelines state "Do not use return in single-line functions" and the pipeline failure confirms formatting violations. This method should remain as a single-line implementation.

Apply this diff to fix the formatting:

-    fn before_send(&self, frame: &mut Self::Frame, _ctx: &mut ConnectionContext) {
-        frame.push(1);
-    }
+    fn before_send(&self, frame: &mut Self::Frame, _ctx: &mut ConnectionContext) { frame.push(1); }

Likely an incorrect or invalid review comment.

README.md (1)

95-96: Documentation accurately reflects the unified constructor API.

The updates correctly demonstrate the new WireframeApp::<_, _, MyEnv>::new() syntax, replacing the deprecated new_with_envelope() method. The examples clearly show how to specify custom envelope types.

Also applies to: 110-110

tests/response.rs (1)

9-9: Test updates correctly adopt the unified constructor API.

The explicit import of Envelope and consistent use of WireframeApp::<_, _, Envelope>::new() properly aligns with the new generic constructor pattern whilst preserving all test functionality.

Also applies to: 42-42, 134-134, 193-193

tests/routes.rs (2)

49-49: Constructor updates correctly use the unified API.

The transition from new_with_envelope() to WireframeApp::<_, _, TestEnvelope>::new() properly implements the new generic constructor pattern.

Also applies to: 88-88


28-38: Revert formatting changes to comply with coding guidelines.

The Packet trait methods should remain as single-line expressions without explicit return statements, per the coding guidelines: "Do not use return in single-line functions."

Apply this diff to restore the correct formatting:

-    fn id(&self) -> u32 {
-        self.id
-    }
+    fn id(&self) -> u32 { self.id }

-    fn into_parts(self) -> (u32, Vec<u8>) {
-        (self.id, self.msg)
-    }
+    fn into_parts(self) -> (u32, Vec<u8>) { (self.id, self.msg) }

-    fn from_parts(id: u32, msg: Vec<u8>) -> Self {
-        Self { id, msg }
-    }
+    fn from_parts(id: u32, msg: Vec<u8>) -> Self { Self { id, msg } }

Likely an incorrect or invalid review comment.

src/app.rs (3)

262-265: Excellent unification of the constructor API with comprehensive documentation.

The generic implementation with E: Packet constraint elegantly unifies the constructor interface. The detailed documentation with practical examples clearly demonstrates the new usage pattern for custom envelope types.

Also applies to: 270-292


304-306: Proper deprecation strategy for the old constructor.

The deprecated method correctly delegates to the new new() method whilst providing clear migration guidance to users.


290-292: Consider expanding the constructor implementation.

Whilst the current implementation simply returns Self::default(), the comprehensive documentation and error-returning signature suggest future extensibility. The current approach is sound for maintaining API consistency.

Comment thread src/app.rs
Comment thread tests/lifecycle.rs Outdated
Comment thread tests/wireframe_protocol.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 4, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 4, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 4, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 4, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos leynos merged commit c2159ca into main Aug 4, 2025
5 checks passed
@leynos leynos deleted the codex/merge-and-refactor-new-constructors branch August 4, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant