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

Method encode

src/balancerd/src/codec.rs:145–157  ·  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

143 /// Encode a backend message into `dst`.
144 /// If this function returns an error result, `dst` is left unmodified.
145 fn encode(&mut self, msg: BackendMessage, dst: &mut BytesMut) -> Result<(), io::Error> {
146 // Record the starting position so we can truncate on error.
147 // This prevents partial messages from being left in the buffer,
148 // which could be sent to the client and cause "lost synchronization" errors.
149 let start = dst.len();
150 match self.encode_inner(msg, dst) {
151 Ok(()) => Ok(()),
152 Err(e) => {
153 dst.truncate(start);
154 Err(e)
155 }
156 }
157 }
158}
159
160impl Codec {

Callers 2

init_streamMethod · 0.45
cancel_requestFunction · 0.45

Calls 3

lenMethod · 0.45
encode_innerMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected