pub use proto_gen::XorFields; use std::collections::HashMap; pub trait XorFields { fn xor_fields(&mut self); } pub trait CmdID { const CMD_ID: u16; fn get_cmd_id(&self) -> u16 { Self::CMD_ID } } pub trait NapMessage: prost::Message + XorFields + CmdID {} impl NapMessage for T {} include!("../out/_.rs"); include!("../out/bin.rs"); // "repeated bytes" impl XorFields for Vec> { fn xor_fields(&mut self) {} } impl XorFields for Vec where T: XorFields, { fn xor_fields(&mut self) { for item in self.iter_mut() { item.xor_fields(); } } } impl XorFields for HashMap where V: XorFields, { fn xor_fields(&mut self) { for value in self.values_mut() { value.xor_fields(); } } } impl XorFields for Option where T: XorFields, { fn xor_fields(&mut self) { if let Some(value) = self.as_mut() { value.xor_fields(); } } } impl XorFields for Box where T: XorFields, { #[allow(unconditional_recursion)] fn xor_fields(&mut self) { self.xor_fields(); } }