MCPcopy Create free account
hub / github.com/actix/examples / encode

Method encode

websockets/chat-tcp/src/codec.rs:71–80  ·  view source on GitHub ↗
(&mut self, msg: ChatResponse, dst: &mut BytesMut)

Source from the content-addressed store, hash-verified

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

Callers 2

make_encryptedFunction · 0.80
encrypt_payloadsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected