Skip to content

📝 Add docstrings to codex/define-endianness-enum-and-refactor-lengthprefixedprocessor#89

Merged
leynos merged 2 commits intocodex/define-endianness-enum-and-refactor-lengthprefixedprocessorfrom
coderabbitai/docstrings/1xkdW72YLzFPtDuYvRHSlqJDNZV1LOalMMJAsPJaqhzg0bRGbWUfow5qDt3NQhVyRrfHxEpqbapJBjBu3bBO1mqm
Jun 20, 2025
Merged

📝 Add docstrings to codex/define-endianness-enum-and-refactor-lengthprefixedprocessor#89
leynos merged 2 commits intocodex/define-endianness-enum-and-refactor-lengthprefixedprocessorfrom
coderabbitai/docstrings/1xkdW72YLzFPtDuYvRHSlqJDNZV1LOalMMJAsPJaqhzg0bRGbWUfow5qDt3NQhVyRrfHxEpqbapJBjBu3bBO1mqm

Conversation

@coderabbitai
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot commented Jun 20, 2025

Docstrings generation was requested by @leynos.

The following files were modified:

  • src/app.rs
  • src/frame.rs
  • tests/response.rs
These file types are not supported
  • AGENTS.md
  • README.md
  • docs/roadmap.md
  • docs/rust-binary-router-library-design.md
ℹ️ Note

CodeRabbit cannot perform edits on its own pull requests yet.

Summary by Sourcery

Add comprehensive documentation comments to public API methods in frame.rs and app.rs, and annotate tests in response.rs with docstrings to clarify their purpose.

Documentation:

  • Add docstrings for LengthFormat constructors and methods (new, u16_be, u16_le, u32_be, u32_le, read_len, write_len) and its Default implementation
  • Add docstrings for LengthPrefixedProcessor constructors (new, default) and FrameProcessor implementations (decode, encode)
  • Add docstring for WireframeApp::default to describe its initialization

Tests:

  • Add documentation comments to response.rs tests to describe behaviors tested for framing, decoding, encoding errors, and custom endianness roundtrip tests

…prefixedprocessor`

Docstrings generation was requested by @leynos.

* #87 (comment)

The following files were modified:

* `src/app.rs`
* `src/frame.rs`
* `tests/response.rs`
@coderabbitai coderabbitai Bot requested a review from leynos June 20, 2025 14:47
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 20, 2025

Reviewer's Guide

This PR enriches core framing and application components with comprehensive Rust documentation comments, covering length-prefixed framing APIs, application initialization, and the corresponding integration tests.

Class diagram for LengthFormat and LengthPrefixedProcessor with documented methods

classDiagram
    class LengthFormat {
        +usize bytes
        +Endianness endianness
        +const fn new(bytes: usize, endianness: Endianness) -> Self
        +const fn u16_be() -> Self
        +const fn u16_le() -> Self
        +const fn u32_be() -> Self
        +const fn u32_le() -> Self
        +fn read_len(&self, bytes: &[u8]) -> io::Result<usize>
        +fn write_len(&self, len: usize, dst: &mut BytesMut) -> io::Result<()> 
        +fn default() -> Self
    }
    class LengthPrefixedProcessor {
        +LengthFormat format
        +const fn new(format: LengthFormat) -> Self
        +fn default() -> Self
        +fn decode(&self, src: &mut BytesMut) -> Result<Option<Vec<u8>>, std::io::Error>
        +fn encode(&self, frame: &Vec<u8>, dst: &mut BytesMut) -> Result<(), std::io::Error>
    }
    LengthPrefixedProcessor --> LengthFormat : uses
Loading

Class diagram for WireframeApp default initialization

classDiagram
    class WireframeApp {
        +fn default() -> Self
        ...
    }
Loading

File-Level Changes

Change Details Files
Add documentation comments for LengthFormat API
  • Document the new() constructor with parameters and return value
  • Document predefined constructors (u16_be, u16_le, u32_be, u32_le)
  • Document read_len() including parameters, return, and error cases
  • Document write_len() including parameters, return, and error cases
  • Document the Default implementation for LengthFormat
src/frame.rs
Add docstrings for LengthPrefixedProcessor constructors and FrameProcessor methods
  • Document new() constructor with length format parameter and return
  • Document Default impl using the 4-byte big-endian format
  • Document decode() behavior, return semantics (Ok(Some/None)) and error conditions
  • Document encode() behavior and error propagation when writing the length prefix
src/frame.rs
Add docstring for WireframeApp::default initialization
  • Document default() method describing initial setup of routes, services, middleware, and frame processor
src/app.rs
Add descriptive doc comments to response tests
  • Document send_response_encodes_and_frames test for framing and asynchronous decode
  • Document incomplete header decode test ensuring no buffer consumption
  • Document incomplete frame decode test ensuring buffer retention
  • Document send_response write error propagation test
  • Document send_response serialization error propagation test
  • Document two-byte big-endian roundtrip encoding/decoding test
  • Document four-byte little-endian roundtrip encoding/decoding test
tests/response.rs

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 Author

coderabbitai Bot commented Jun 20, 2025

Important

Review skipped

CodeRabbit bot authored PR detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 auto-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.

@leynos
Copy link
Copy Markdown
Owner

leynos commented Jun 20, 2025

@sourcery-ai review

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 @coderabbitai[bot] - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/frame.rs:30` </location>
<code_context>
 impl LengthFormat {
     /// Create a new [`LengthFormat`].
     #[must_use]
-    pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
+    /// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
+///
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Rust convention and the review instruction require that attributes like #[must_use] are placed after the function's doc comment, not before. Please move the attribute below the doc comment for consistency and clarity.
</issue_to_address>

### Comment 2
<location> `src/frame.rs:34` </location>
<code_context>

     /// Two byte big-endian prefix.
     #[must_use]
-    pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
+pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function to follow the required style.
</issue_to_address>

### Comment 3
<location> `src/frame.rs:38` </location>
<code_context>

     /// Two byte little-endian prefix.
     #[must_use]
-    pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 2-byte little-endian length prefix.
+pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as per the review instruction.
</issue_to_address>

### Comment 4
<location> `src/frame.rs:42` </location>
<code_context>

     /// Four byte big-endian prefix.
     #[must_use]
-    pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 4-byte big-endian length prefix.
+pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as required.
</issue_to_address>

### Comment 5
<location> `src/frame.rs:46` </location>
<code_context>

     /// Four byte little-endian prefix.
     #[must_use]
-    pub const fn u32_le() -> Self { Self::new(4, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 4-byte little-endian length prefix.
+pub const fn u32_le() -> Self { Self::new(4, Endianness::Little) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as per the style guide.
</issue_to_address>

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.

Comment thread src/frame.rs Outdated
/// Create a new [`LengthFormat`].
#[must_use]
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
/// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Rust convention and the review instruction require that attributes like #[must_use] are placed after the function's doc comment, not before. Please move the attribute below the doc comment for consistency and clarity.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs Outdated
///
/// # Parameters
/// - `bytes`: The number of bytes used for the length prefix.
/// - `endianness`: The byte order for encoding and decoding the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function to follow the required style.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs Outdated
///
/// # Returns
/// A `LengthFormat` configured with the given size and endianness.
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as per the review instruction.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs
/// Two byte big-endian prefix.
#[must_use]
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
/// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as required.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }

/// Two byte little-endian prefix.
#[must_use]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as per the style guide.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

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 @coderabbitai[bot] - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/frame.rs:30` </location>
<code_context>
 impl LengthFormat {
     /// Create a new [`LengthFormat`].
     #[must_use]
-    pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
+    /// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
+///
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `new` uses 'Creates a new...' instead of the imperative 'Create a new...'. Please use the imperative mood for consistency with Rust documentation guidelines and the review instructions.
</issue_to_address>

### Comment 2
<location> `src/frame.rs:34` </location>
<code_context>

     /// Two byte big-endian prefix.
     #[must_use]
-    pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
+pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `u16_be` uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.
</issue_to_address>

### Comment 3
<location> `src/frame.rs:38` </location>
<code_context>

     /// Two byte little-endian prefix.
     #[must_use]
-    pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 2-byte little-endian length prefix.
+pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `u16_le` uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.
</issue_to_address>

### Comment 4
<location> `src/frame.rs:42` </location>
<code_context>

     /// Four byte big-endian prefix.
     #[must_use]
-    pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 4-byte big-endian length prefix.
+pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `u32_be` uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.
</issue_to_address>

### Comment 5
<location> `src/frame.rs:46` </location>
<code_context>

     /// Four byte little-endian prefix.
     #[must_use]
-    pub const fn u32_le() -> Self { Self::new(4, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 4-byte little-endian length prefix.
+pub const fn u32_le() -> Self { Self::new(4, Endianness::Little) }
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `u32_le` uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.
</issue_to_address>

### Comment 6
<location> `src/frame.rs:155` </location>
<code_context>

 impl Default for LengthFormat {
-    fn default() -> Self { Self::u32_be() }
+    /// Returns a `LengthFormat` using a 4-byte big-endian length prefix.
+///
+/// This is the default format for length-prefixed framing.
</code_context>

<issue_to_address>
Use imperative mood in doc comments for default implementations (e.g., 'Return' instead of 'Returns').

The doc comment for `default` uses 'Returns a...' instead of 'Return a...'. Please use the imperative mood.
</issue_to_address>

### Comment 7
<location> `src/frame.rs:199` </location>
<code_context>
     /// Construct a processor with the provided [`LengthFormat`].
     #[must_use]
-    pub const fn new(format: LengthFormat) -> Self { Self { format } }
+    /// Creates a new `LengthPrefixedProcessor` with the specified length prefix format.
+///
+/// # Parameters
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `LengthPrefixedProcessor::new` uses 'Creates a new...' instead of 'Create a new...'. Please use the imperative mood.
</issue_to_address>

### Comment 8
<location> `src/frame.rs:210` </location>
<code_context>

 impl Default for LengthPrefixedProcessor {
-    fn default() -> Self { Self::new(LengthFormat::default()) }
+    /// Creates a `LengthPrefixedProcessor` using the default length format (4-byte big-endian prefix).
+///
+/// # Returns
</code_context>

<issue_to_address>
Use imperative mood in doc comments for default implementations (e.g., 'Create' instead of 'Creates').

The doc comment for `LengthPrefixedProcessor::default` uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.
</issue_to_address>

### Comment 9
<location> `src/frame.rs:221` </location>
<code_context>
     type Frame = Vec<u8>;
     type Error = std::io::Error;

+    /// Attempts to decode a single length-prefixed frame from the source buffer.
+    ///
+    /// Returns `Ok(Some(frame))` if a complete frame is available, `Ok(None)` if
</code_context>

<issue_to_address>
Use imperative mood in doc comments for method actions (e.g., 'Attempt' instead of 'Attempts').

The doc comment for `decode` uses 'Attempts to decode...' instead of 'Attempt to decode...'. Please use the imperative mood.
</issue_to_address>

### Comment 10
<location> `src/frame.rs:240` </location>
<code_context>
         Ok(Some(src.split_to(len).to_vec()))
     }

+    /// Encodes a frame by prefixing it with its length and appending it to the destination buffer.
+    ///
+    /// The length prefix format is determined by the processor's configuration. Returns an error
</code_context>

<issue_to_address>
Use imperative mood in doc comments for method actions (e.g., 'Encode' instead of 'Encodes').

The doc comment for `encode` uses 'Encodes a frame...' instead of 'Encode a frame...'. Please use the imperative mood.
</issue_to_address>

### Comment 11
<location> `src/app.rs:150` </location>
<code_context>
     S: Serializer + Default,
     C: Send + 'static,
 {
+    /// Creates a new `WireframeApp` instance with default configuration.
+    ///
+    /// Initialises empty routes, services, middleware, and application data. Sets the
</code_context>

<issue_to_address>
Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for `WireframeApp::default` uses 'Creates a new...' instead of 'Create a new...'. Please use the imperative mood.
</issue_to_address>

### Comment 12
<location> `src/frame.rs:30` </location>
<code_context>
 impl LengthFormat {
     /// Create a new [`LengthFormat`].
     #[must_use]
-    pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
+    /// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
+///
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Rust convention and the review instruction require that attributes like #[must_use] come after the function's doc comment, not before. Please move the attribute below the doc comment for consistency and clarity.
</issue_to_address>

### Comment 13
<location> `src/frame.rs:38` </location>
<code_context>

     /// Two byte little-endian prefix.
     #[must_use]
-    pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 2-byte little-endian length prefix.
+pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function.
</issue_to_address>

### Comment 14
<location> `src/frame.rs:42` </location>
<code_context>

     /// Four byte big-endian prefix.
     #[must_use]
-    pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 4-byte big-endian length prefix.
+pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function.
</issue_to_address>

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.

Comment thread src/frame.rs Outdated
/// Create a new [`LengthFormat`].
#[must_use]
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
/// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for new uses 'Creates a new...' instead of the imperative 'Create a new...'. Please use the imperative mood for consistency with Rust documentation guidelines and the review instructions.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/frame.rs Outdated
///
/// # Parameters
/// - `bytes`: The number of bytes used for the length prefix.
/// - `endianness`: The byte order for encoding and decoding the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for u16_be uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/frame.rs Outdated
///
/// # Returns
/// A `LengthFormat` configured with the given size and endianness.
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for u16_le uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/frame.rs
/// Two byte big-endian prefix.
#[must_use]
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
/// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for u32_be uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/frame.rs
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }

/// Two byte little-endian prefix.
#[must_use]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for u32_le uses 'Creates a...' instead of 'Create a...'. Please use the imperative mood.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/frame.rs
Ok(Some(src.split_to(len).to_vec()))
}

/// Encodes a frame by prefixing it with its length and appending it to the destination buffer.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for method actions (e.g., 'Encode' instead of 'Encodes').

The doc comment for encode uses 'Encodes a frame...' instead of 'Encode a frame...'. Please use the imperative mood.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/app.rs
S: Serializer + Default,
C: Send + 'static,
{
/// Creates a new `WireframeApp` instance with default configuration.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (review_instructions): Use imperative mood in doc comments for constructors (e.g., 'Create' instead of 'Creates').

The doc comment for WireframeApp::default uses 'Creates a new...' instead of 'Create a new...'. Please use the imperative mood.

Review instructions:

Path patterns: **/*

Instructions:
Use the imperative mood when writing pull request review feedback.

Comment thread src/frame.rs Outdated
/// Create a new [`LengthFormat`].
#[must_use]
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
/// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Rust convention and the review instruction require that attributes like #[must_use] come after the function's doc comment, not before. Please move the attribute below the doc comment for consistency and clarity.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs Outdated
///
/// # Returns
/// A `LengthFormat` configured with the given size and endianness.
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs
/// Two byte big-endian prefix.
#[must_use]
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
/// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

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 @coderabbitai[bot] - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/frame.rs:30` </location>
<code_context>
 impl LengthFormat {
     /// Create a new [`LengthFormat`].
     #[must_use]
-    pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
+    /// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
+///
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Rust convention and the review instruction require that attributes like #[must_use] are placed after the function's doc comment, not before. Please move the attribute below the doc comment for consistency and clarity.
</issue_to_address>

### Comment 2
<location> `src/frame.rs:34` </location>
<code_context>

     /// Two byte big-endian prefix.
     #[must_use]
-    pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
+pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function to follow the required style.
</issue_to_address>

### Comment 3
<location> `src/frame.rs:38` </location>
<code_context>

     /// Two byte little-endian prefix.
     #[must_use]
-    pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 2-byte little-endian length prefix.
+pub const fn u16_le() -> Self { Self::new(2, Endianness::Little) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as well.
</issue_to_address>

### Comment 4
<location> `src/frame.rs:42` </location>
<code_context>

     /// Four byte big-endian prefix.
     #[must_use]
-    pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
+    /// Creates a `LengthFormat` for a 4-byte big-endian length prefix.
+pub const fn u32_be() -> Self { Self::new(4, Endianness::Big) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as well.
</issue_to_address>

### Comment 5
<location> `src/frame.rs:46` </location>
<code_context>

     /// Four byte little-endian prefix.
     #[must_use]
-    pub const fn u32_le() -> Self { Self::new(4, Endianness::Little) }
+    /// Creates a `LengthFormat` for a 4-byte little-endian length prefix.
+pub const fn u32_le() -> Self { Self::new(4, Endianness::Little) }
</code_context>

<issue_to_address>
Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as well.
</issue_to_address>

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.

Comment thread src/frame.rs Outdated
/// Create a new [`LengthFormat`].
#[must_use]
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
/// Creates a new `LengthFormat` with the specified number of bytes and endianness for the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Rust convention and the review instruction require that attributes like #[must_use] are placed after the function's doc comment, not before. Please move the attribute below the doc comment for consistency and clarity.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs Outdated
///
/// # Parameters
/// - `bytes`: The number of bytes used for the length prefix.
/// - `endianness`: The byte order for encoding and decoding the length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function to follow the required style.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs Outdated
///
/// # Returns
/// A `LengthFormat` configured with the given size and endianness.
pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as well.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs
/// Two byte big-endian prefix.
#[must_use]
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }
/// Creates a `LengthFormat` for a 2-byte big-endian length prefix.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as well.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

Comment thread src/frame.rs
pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) }

/// Two byte little-endian prefix.
#[must_use]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Function attribute #[must_use] is placed before the doc comment; it should be after the doc comment.

Please move the #[must_use] attribute below the doc comment for this function as well.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

@leynos leynos merged commit 2cb4d3e into codex/define-endianness-enum-and-refactor-lengthprefixedprocessor Jun 20, 2025
1 check passed
@leynos leynos deleted the coderabbitai/docstrings/1xkdW72YLzFPtDuYvRHSlqJDNZV1LOalMMJAsPJaqhzg0bRGbWUfow5qDt3NQhVyRrfHxEpqbapJBjBu3bBO1mqm branch June 20, 2025 15:02
leynos added a commit that referenced this pull request Jun 20, 2025
* Add configurable length format for frames

* 📝 Add docstrings to `codex/define-endianness-enum-and-refactor-lengthprefixedprocessor` (#89)

* 📝 Add docstrings to `codex/define-endianness-enum-and-refactor-lengthprefixedprocessor`

Docstrings generation was requested by @leynos.

* #87 (comment)

The following files were modified:

* `src/app.rs`
* `src/frame.rs`
* `tests/response.rs`

* Move attributes below doc comments (#90)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Leynos <leynos@troubledskies.net>

* Refine length prefix handling

* Use rstest for length format tests

* Fix syntax errors and update tests (#91)

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant