codec: fix is_readable should be buffer empty or not (#7912)

This commit is contained in:
cui
2026-02-16 17:33:35 +01:00
committed by GitHub
parent 00d10c22f8
commit 96f64f4ee2
2 changed files with 55 additions and 1 deletions
+2 -1
View File
@@ -65,6 +65,7 @@ impl Default for WriteFrame {
impl From<BytesMut> for ReadFrame {
fn from(mut buffer: BytesMut) -> Self {
let is_readable = !buffer.is_empty();
let size = buffer.capacity();
if size < INITIAL_CAPACITY {
buffer.reserve(INITIAL_CAPACITY - size);
@@ -72,7 +73,7 @@ impl From<BytesMut> for ReadFrame {
Self {
buffer,
is_readable: size > 0,
is_readable,
eof: false,
has_errored: false,
}