#[cfg(feature = "derive")] mod tests { use bufferfish_core::{Bufferfish, Encodable}; use bufferfish_derive::Encode; #[allow(dead_code)] enum PacketId { Ping, } impl From for u16 { fn from(packet_id: PacketId) -> u16 { match packet_id { PacketId::Ping => 0, } } } #[derive(Encode, Debug)] #[bufferfish(PacketId::Ping)] struct Foo { bar: u8, } #[test] fn encode_struct() { let foo = Foo { bar: 42 }; let bf: Bufferfish = foo.to_bufferfish().unwrap(); assert_eq!(bf.len(), 3); } }