📝 Add docstrings to codex/define-endianness-enum-and-refactor-lengthprefixedprocessor#89
Conversation
…prefixedprocessor` Docstrings generation was requested by @leynos. * #87 (comment) The following files were modified: * `src/app.rs` * `src/frame.rs` * `tests/response.rs`
Reviewer's GuideThis 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 methodsclassDiagram
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
Class diagram for WireframeApp default initializationclassDiagram
class WireframeApp {
+fn default() -> Self
...
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedCodeRabbit bot authored PR detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@sourcery-ai review |
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /// 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. |
There was a problem hiding this comment.
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
| /// | ||
| /// # Parameters | ||
| /// - `bytes`: The number of bytes used for the length prefix. | ||
| /// - `endianness`: The byte order for encoding and decoding the length prefix. |
There was a problem hiding this comment.
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
| /// | ||
| /// # Returns | ||
| /// A `LengthFormat` configured with the given size and endianness. | ||
| pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } } |
There was a problem hiding this comment.
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
| /// 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. |
There was a problem hiding this comment.
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
| pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) } | ||
|
|
||
| /// Two byte little-endian prefix. | ||
| #[must_use] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /// 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. |
There was a problem hiding this comment.
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.
| /// | ||
| /// # Parameters | ||
| /// - `bytes`: The number of bytes used for the length prefix. | ||
| /// - `endianness`: The byte order for encoding and decoding the length prefix. |
There was a problem hiding this comment.
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.
| /// | ||
| /// # Returns | ||
| /// A `LengthFormat` configured with the given size and endianness. | ||
| pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } } |
There was a problem hiding this comment.
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.
| /// 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. |
There was a problem hiding this comment.
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.
| pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) } | ||
|
|
||
| /// Two byte little-endian prefix. | ||
| #[must_use] |
There was a problem hiding this comment.
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.
| Ok(Some(src.split_to(len).to_vec())) | ||
| } | ||
|
|
||
| /// Encodes a frame by prefixing it with its length and appending it to the destination buffer. |
There was a problem hiding this comment.
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.
| S: Serializer + Default, | ||
| C: Send + 'static, | ||
| { | ||
| /// Creates a new `WireframeApp` instance with default configuration. |
There was a problem hiding this comment.
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.
| /// 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. |
There was a problem hiding this comment.
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
| /// | ||
| /// # Returns | ||
| /// A `LengthFormat` configured with the given size and endianness. | ||
| pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } } |
There was a problem hiding this comment.
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
| /// 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /// 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. |
There was a problem hiding this comment.
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
| /// | ||
| /// # Parameters | ||
| /// - `bytes`: The number of bytes used for the length prefix. | ||
| /// - `endianness`: The byte order for encoding and decoding the length prefix. |
There was a problem hiding this comment.
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
| /// | ||
| /// # Returns | ||
| /// A `LengthFormat` configured with the given size and endianness. | ||
| pub const fn new(bytes: usize, endianness: Endianness) -> Self { Self { bytes, endianness } } |
There was a problem hiding this comment.
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
| /// 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. |
There was a problem hiding this comment.
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
| pub const fn u16_be() -> Self { Self::new(2, Endianness::Big) } | ||
|
|
||
| /// Two byte little-endian prefix. | ||
| #[must_use] |
There was a problem hiding this comment.
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
2cb4d3e
into
codex/define-endianness-enum-and-refactor-lengthprefixedprocessor
* 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>
Docstrings generation was requested by @leynos.
The following files were modified:
src/app.rssrc/frame.rstests/response.rsThese file types are not supported
AGENTS.mdREADME.mddocs/roadmap.mddocs/rust-binary-router-library-design.mdℹ️ Note
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:
Tests: