bytevec::bytevec_impls!
[−]
[src]
macro_rules! bytevec_impls { {$($(#[$attr:meta])* struct $name:ident {$($field:ident : $t:ty),*})*} => { ... }; }
The bytevec_impls macro
This macro allows the user to declare an arbitrary number of structures that
automatically implement both the ByteEncodable and ByteDecodable traits,
as long as all of the fields also implement both traits.
bytevec_impls! { #[derive(PartialEq, Eq, Debug)] struct Point { x: u32, y: u32 } } fn main() { let p1 = Point {x: 32, y: 436}; let bytes = p1.encode().unwrap(); let p2 = Point::decode(&bytes).unwrap(); assert_eq!(p1, p2); }