Additionally, a new implementation of the AsRef<CheetahString> trait is introduced for the CheetahString struct. In src/serde.rs, the serialization logic for the CheetahString struct is updated to use the newly public EMPTY_STRING constant when handling the InnerString::Empty variant during serial...
RawNetworkMessage::new(Magic::from_bytes([57, 0, 0, 0]), msg ); assert_eq!(deserialize::<RawNetworkMessage>(&serialize(&raw_msg)).unwrap(), raw_msg); } } @@ -695,7 +706,7 @@ mod test { #[test] #[rustfmt::skip] fn serialize_verack_test() { assert_eq!(serialize(&Raw...
Serde 提供了 Rust 基础类型和标准库类型的 Serialize 和 Deserialize 实现。 对于自定义类型,我们可以自行实现 Serialize 和 Deserialize trait。另外,Serde 提供一个宏 serde_derive 来自动为结构体类型和枚举类型生成 Serialize 和 Deserialize 实现。该特性需要 Rust 编译器版本在 1.31及以上,并且在 Cargo.toml 文...
// https://github.com/mozilla/mp4parse-rust/pull/239 fn main() { let path = std::env::args_os().nth(1).expect("Please specify path to an AVIF file to optimize"); let avif = fs::read(&path).expect("Can't load input image"); let mut ctx = mp4parse::AvifContext::new();...