Skip to content

Commit b42f850

Browse files
committed
Freeze byte buffer before storing in ResponseData
1 parent 9caefff commit b42f850

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tokio-imap/src/proto.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bytes::{BufMut, BytesMut};
1+
use bytes::{BufMut, Bytes, BytesMut};
22

33
use futures;
44

@@ -56,7 +56,7 @@ impl<'a> Decoder for ImapCodec {
5656
));
5757
},
5858
};
59-
let raw = buf.split_to(rsp_len);
59+
let raw = buf.split_to(rsp_len).freeze();
6060
self.decode_need_message_bytes = 0;
6161
Ok(Some(ResponseData { raw, response }))
6262
}
@@ -76,7 +76,7 @@ impl Encoder for ImapCodec {
7676

7777
#[derive(Debug)]
7878
pub struct ResponseData {
79-
raw: BytesMut,
79+
raw: Bytes,
8080
// This reference is really scoped to the lifetime of the `raw`
8181
// member, but unfortunately Rust does not allow that yet. It
8282
// is transmuted to `'static` by the `Decoder`, instead, and

0 commit comments

Comments
 (0)