use std::io::Read;
use bytes::{BytesMut, BufMut, Buf};

fn main() {
    let mut buf = BytesMut::new();
    buf.put_u8(0x20);
    buf.put_u16(0x1234);
    buf.put_u8(0x20);
    buf.put_u16_le(0x1234);
    buf.put(&b"hello world"[..]);

    println!("{:?}", &buf);
    println!("{:x?}", &buf[..]);

    let mut buf2 = BytesMut::with_capacity(8);
    println!("{:x?}", &buf2[..]);
    buf2.resize(8, 0x00);
    println!("{:x?}", &buf2[..]);

    let mut buf3 = BytesMut::with_capacity(16);
    buf3.put_slice(b"hello world");
    let mut reader = buf3.reader();
    let mut vec = vec![];
    let len = reader.read_to_end(&mut vec);
    println!("Len: {:?}  -> {:x?}", len, vec);
}
