pub trait ProtocolEncode<'en, Context = ()> { fn encode(&self, buf: &mut Vec) -> Result<(), crate::Error> where Self: ProtocolEncode<'en, ()>, { self.encode_with(buf, ()) } fn encode_with(&self, buf: &mut Vec, context: Context) -> Result<(), crate::Error>; } impl ProtocolEncode<'_, C> for &'_ [u8] { fn encode_with(&self, buf: &mut Vec, _context: C) -> Result<(), crate::Error> { buf.extend_from_slice(self); Ok(()) } }