Skip to content

Commit

Permalink
Clarify initial frame data detection code
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-casperlabs committed Feb 28, 2024
1 parent 5ccc9d6 commit 57bed06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ impl<const N: usize> JulietProtocol<N> {
) -> Outcome<CompletedRead, OutgoingMessage> {
// First, attempt to complete a frame.
loop {
// We do not have enough data to extract a header, indicate and return.
if buffer.len() < Header::SIZE {
// We do not have enough data to extract a header, indicate and return.
return Outcome::incomplete(Header::SIZE - buffer.len());
}

Expand Down
4 changes: 3 additions & 1 deletion src/protocol/multiframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ impl InitialFrameData {
/// Returns whether or not the initial frame data describes a complete initial frame.
#[inline(always)]
fn is_complete(self) -> bool {
self.segment_len >= self.payload_size as usize
debug_assert!(self.segment_len <= self.payload_size as usize);

self.segment_len == self.payload_size as usize
}
}

Expand Down

0 comments on commit 57bed06

Please sign in to comment.