Add more conversion impls

This commit is contained in:
Carl Lerche
2016-11-02 22:27:00 -07:00
parent a367a723d8
commit 4886b44516
2 changed files with 20 additions and 1 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
use {Buf, BufMut, BytesMut};
use {Buf, BufMut, Bytes, BytesMut};
use std::{cmp, fmt};
@@ -186,6 +186,19 @@ impl BufMut for ByteBuf {
}
}
impl From<ByteBuf> for Bytes {
fn from(src: ByteBuf) -> Bytes {
let bytes = BytesMut::from(src);
bytes.freeze()
}
}
impl From<ByteBuf> for BytesMut {
fn from(src: ByteBuf) -> BytesMut {
src.mem
}
}
impl fmt::Debug for ByteBuf {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
self.bytes().fmt(fmt)