Skip to content

Commit 1bf37ce

Browse files
committed
rust: add Frome<Frame> impls for Bytes/BytesMut
1 parent 076a244 commit 1bf37ce

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

rust/sbp/src/de.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
time::{Duration, Instant},
55
};
66

7-
use bytes::{Buf, BytesMut};
7+
use bytes::{Buf, Bytes, BytesMut};
88
use dencode::FramedRead;
99

1010
#[cfg(feature = "async")]
@@ -360,6 +360,18 @@ impl Frame {
360360
}
361361
}
362362

363+
impl From<Frame> for BytesMut {
364+
fn from(Frame(buf): Frame) -> Self {
365+
buf
366+
}
367+
}
368+
369+
impl From<Frame> for Bytes {
370+
fn from(Frame(buf): Frame) -> Self {
371+
buf.into()
372+
}
373+
}
374+
363375
struct TimeoutDecoderImpl<D> {
364376
timeout_duration: Duration,
365377
last_msg_received: Instant,

0 commit comments

Comments
 (0)