aboutsummaryrefslogtreecommitdiff
path: root/src/message.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-21 18:15:07 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-21 18:15:07 +0200
commit26989bba1409bfc093e58ef98e75885b10ad7c1c (patch)
tree92c53f668f1c5d197df026d96bbf4a0cdb7c2bbb /src/message.rs
parent9dffa812c43470ee8a29c23c3a1be73085e25843 (diff)
downloadnetapp-26989bba1409bfc093e58ef98e75885b10ad7c1c.tar.gz
netapp-26989bba1409bfc093e58ef98e75885b10ad7c1c.zip
Use Bytes instead of Vec<u8>
Diffstat (limited to 'src/message.rs')
-rw-r--r--src/message.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/message.rs b/src/message.rs
index dbcc857..6d50254 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -192,8 +192,8 @@ impl Framing {
// required because otherwise the borrow-checker complains
let Framing { direct, stream } = self;
- let res = stream::once(async move { Ok(u32::to_be_bytes(len).to_vec()) })
- .chain(stream::once(async move { Ok(direct) }));
+ let res = stream::once(async move { Ok(u32::to_be_bytes(len).to_vec().into()) })
+ .chain(stream::once(async move { Ok(direct.into()) }));
if let Some(stream) = stream {
Box::pin(res.chain(stream))
@@ -217,7 +217,7 @@ impl Framing {
let mut len = [0; 4];
len.copy_from_slice(&packet[..4]);
let len = u32::from_be_bytes(len);
- packet.drain(..4);
+ packet = packet.slice(4..);
let mut buffer = Vec::new();
let len = len as usize;
@@ -226,7 +226,7 @@ impl Framing {
buffer.extend_from_slice(&packet[..max_cp]);
if buffer.len() == len {
- packet.drain(..max_cp);
+ packet = packet.slice(max_cp..);
break;
}
packet = stream