(&mut self, msg: ChatResponse, dst: &mut BytesMut)
| 69 | type Error = io::Error; |
| 70 | |
| 71 | fn encode(&mut self, msg: ChatResponse, dst: &mut BytesMut) -> Result<(), Self::Error> { |
| 72 | let msg = json::to_string(&msg).unwrap(); |
| 73 | let msg_ref: &[u8] = msg.as_ref(); |
| 74 | |
| 75 | dst.reserve(msg_ref.len() + 2); |
| 76 | dst.put_u16(msg_ref.len() as u16); |
| 77 | dst.put(msg_ref); |
| 78 | |
| 79 | Ok(()) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /// Codec for Server -> Client transport |
no outgoing calls
no test coverage detected