chore: reorg

This commit is contained in:
2020-10-17 12:01:53 +08:00
parent 0e7cc78585
commit bf1a0343cc
32 changed files with 0 additions and 0 deletions

21
__serialization/bytes/Cargo.lock generated Normal file
View File

@@ -0,0 +1,21 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bytes"
version = "0.1.0"
dependencies = [
"bytes 0.5.6",
"hex",
]
[[package]]
name = "bytes"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "hex"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"

View File

@@ -0,0 +1,11 @@
[package]
name = "bytes"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bytes = "0.5.6"
hex = "0.4.2"

View File

@@ -0,0 +1,24 @@
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());
}