Encodes a protocol message into the destination buffer. # Performance Time complexity is O(n) where n is the size of the message being encoded. Space complexity depends on the implementation of `T::encode()`. # Errors Returns an error if the encoding operation fails.
(&mut self, item: T, dst: &mut BytesMut)
| 78 | /// |
| 79 | /// Returns an error if the encoding operation fails. |
| 80 | fn encode(&mut self, item: T, dst: &mut BytesMut) -> Result<(), Self::Error> { |
| 81 | let mut buffer = Buffer::new(dst); |
| 82 | |
| 83 | item.encode(&mut buffer) |
| 84 | .change_context(io::Error::from(io::ErrorKind::InvalidData)) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | impl<T> Decoder for ProtocolCodec<T> |