use bytes::{Bytes, BytesMut, Buf, BufMut};

fn main() {
    println!("Run #test_bytes()");
    test_bytes();
    println!("Run #test_bytes_mut()");
    test_bytes_mut();
}

fn test_bytes() {
    let mut buf = Bytes::from(&b"1122334455"[..]);
    let v1 = buf.get_u16();
    let v2 = buf.get_u16();
    println!("v1: {}, v2: {}", v1, v2);
}

fn test_bytes_mut() {
    let mut buf = BytesMut::with_capacity(2);
    println!("[{}], len: {}", hex::encode(buf.bytes()), buf.len());
    buf.put_u64(112233445566778899);
    println!("[{}], len: {}", hex::encode(buf.bytes()), buf.len());
    buf.put_u16(1);
    println!("[{}], len: {}", hex::encode(buf.bytes()), buf.len());
}
