MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / send_protocol_pump

Method send_protocol_pump

src/pglite/postgres_mod.rs:1192–1229  ·  view source on GitHub ↗
(
        &mut self,
        payload: &[u8],
        continuation_prefix: impl FnOnce() -> Vec<u8>,
    )

Source from the content-addressed store, hash-verified

1190 }
1191
1192 pub(crate) fn send_protocol_pump(
1193 &mut self,
1194 payload: &[u8],
1195 continuation_prefix: impl FnOnce() -> Vec<u8>,
1196 ) -> Result<ProtocolPumpOutcome> {
1197 {
1198 let _phase = timing::phase("postgres.protocol.ensure_started");
1199 self.start_protocol()?;
1200 }
1201 if payload.is_empty() {
1202 return Ok(ProtocolPumpOutcome::Buffered(Vec::new()));
1203 }
1204 ensure!(
1205 self.protocol_stdio_attachment.is_some(),
1206 "WASIX protocol pump requires an attached stream"
1207 );
1208 let previous_mode = self.set_protocol_transport(ProtocolTransportMode::Hybrid)?;
1209 ensure!(
1210 previous_mode == ProtocolTransportMode::Buffered,
1211 "WASIX protocol transport was not buffered before protocol pump"
1212 );
1213 let result = self.send_protocol_inner(payload);
1214 let active = self.protocol_stream_active().unwrap_or(false);
1215 if active {
1216 self.set_protocol_stream_prefix(continuation_prefix())?;
1217 let stream_result = result.and_then(|_| self.serve_protocol_stream_inner());
1218 let restore_result = self.restore_protocol_transport(previous_mode);
1219 let clear_result = self.clear_protocol_stream_prefix();
1220 stream_result.and(restore_result).and(clear_result)?;
1221 Ok(ProtocolPumpOutcome::Streamed)
1222 } else {
1223 let output = result;
1224 let restore_result = self.restore_protocol_transport(previous_mode);
1225 restore_result?;
1226 let output = output?;
1227 Ok(ProtocolPumpOutcome::Buffered(output))
1228 }
1229 }
1230
1231 fn send_protocol_inner(&mut self, payload: &[u8]) -> Result<Vec<u8>> {
1232 self.reset_backend_c_timings()?;

Callers 1

Calls 9

phaseFunction · 0.85
start_protocolMethod · 0.80
send_protocol_innerMethod · 0.80

Tested by

no test coverage detected