1 Star 11 Fork 4

JanKinCai / jppe-rs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test_type_hex_bytes.rs 687 Bytes
一键复制 编辑 原始数据 按行查看 历史
use jppe::{BorrowByteDecode, BorrowByteEncode};
use jppe::fields::HexBytes;
use jppe_derive::{BorrowByteDecode, BorrowByteEncode};
#[derive(Debug, PartialEq, Eq, BorrowByteDecode, BorrowByteEncode)]
pub struct HexBytesExample<'a> {
pub length: u8,
#[jppe(length="length")]
pub value: HexBytes<'a>,
}
#[test]
fn test_type_hex_bytes() {
let (input, value) = HexBytesExample::decode(b"\x09jankincai", None, None).unwrap();
assert_eq!(value.length, 9);
assert_eq!(value.value.to_string(), "6a616e6b696e636169");
assert_eq!(input.is_empty(), true);
let mut buf = Vec::new();
value.encode(&mut buf, None, None);
assert_eq!(buf, b"\x09jankincai");
}
Rust
1
https://gitee.com/JanKinCai/jppe-rs.git
git@gitee.com:JanKinCai/jppe-rs.git
JanKinCai
jppe-rs
jppe-rs
master

搜索帮助