MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / encode

Method encode

src/pgwire/src/codec.rs:250–262  ·  view source on GitHub ↗

Encode a backend message into `dst`. If this function returns an error result, `dst` is left unmodified.

(&mut self, msg: BackendMessage, dst: &mut BytesMut)

Source from the content-addressed store, hash-verified

248 /// Encode a backend message into `dst`.
249 /// If this function returns an error result, `dst` is left unmodified.
250 fn encode(&mut self, msg: BackendMessage, dst: &mut BytesMut) -> Result<(), io::Error> {
251 // Record the starting position so we can truncate on error.
252 // This prevents partial messages from being left in the buffer,
253 // which could be sent to the client and cause "lost synchronization" errors.
254 let start = dst.len();
255 match self.encode_inner(msg, dst) {
256 Ok(()) => Ok(()),
257 Err(e) => {
258 dst.truncate(start);
259 Err(e)
260 }
261 }
262 }
263}
264
265impl Codec {

Callers 1

encode_innerMethod · 0.45

Calls 3

lenMethod · 0.45
encode_innerMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected