diff --git a/src/proto/base_codec.rs b/src/proto/base_codec.rs index b228e8b..6247707 100644 --- a/src/proto/base_codec.rs +++ b/src/proto/base_codec.rs @@ -162,6 +162,8 @@ where /// This trait is implemented by types that can be encoded into messages with /// a `ProtoEncoder`. /// Only here to enable `ProtoEncoder::encode_vec`. +/// Attempting to implement Encode for Vec otherwise fails because none of +/// the types involved are defined in this crate. pub trait ProtoEncode { /// Attempts to encode `self` with the given encoder. fn encode(&self, encoder: &mut ProtoEncoder) -> io::Result<()>; @@ -308,6 +310,12 @@ impl ProtoEncode for Vec { } } +impl<'a, T: ProtoEncode> Encode<&'a T> for BytesMut { + fn encode(&mut self, value: &'a T) -> io::Result<()> { + value.encode(&mut ProtoEncoder::new(self)) + } +} + /*=======* * TESTS * *=======*/