jetsung Rust 十六进制字符串转二进制数据(bytes) use bytes::Bytes; use hex::FromHex; let hexstr = "aabbcc"; let data: Vec<u8> = Vec::from_hex(hexstr).expect("invalid hex string"); let bytedata = Bytes::from(data); Cargo.toml # hex = "0.4.3" # bytes = "1.3.0"