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

Method read_cstr

src/pgwire-common/src/codec.rs:278–286  ·  view source on GitHub ↗

Returns the next null-terminated string. The null character is not included the returned string. The cursor is advanced past the null- terminated string. If there is no null byte remaining in the string, returns `CodecError::StringNoTerminator`. If the string is not valid UTF-8, returns an `io::Error` with an error kind of `io::ErrorKind::InvalidInput`. NOTE(benesch): it is possible that returni

(&mut self)

Source from the content-addressed store, hash-verified

276 /// not UTF-8 encoded. At the moment, we've not discovered a need for this,
277 /// though, and using proper strings is convenient.
278 pub fn read_cstr(&mut self) -> Result<&'a str, io::Error> {
279 if let Some(pos) = self.buf.iter().position(|b| *b == 0) {
280 let val = std::str::from_utf8(&self.buf[..pos]).map_err(input_err)?;
281 self.advance(pos + 1);
282 Ok(val)
283 } else {
284 Err(input_err(CodecError::StringNoTerminator))
285 }
286 }
287
288 /// Reads the next 16-bit signed integer, advancing the cursor by two
289 /// bytes.

Callers 11

decode_passwordFunction · 0.80
decode_queryFunction · 0.80
decode_parseFunction · 0.80
decode_closeFunction · 0.80
decode_describeFunction · 0.80
decode_bindFunction · 0.80
decode_executeFunction · 0.80
decode_copy_failFunction · 0.80
decode_startupFunction · 0.80
decode_passwordFunction · 0.80

Calls 4

input_errFunction · 0.85
positionMethod · 0.45
iterMethod · 0.45
advanceMethod · 0.45

Tested by

no test coverage detected