MCPcopy Create free account
hub / github.com/erans/pgsqlite / read_cstring

Method read_cstring

src/protocol/parser.rs:348–363  ·  view source on GitHub ↗
(&self, cursor: &mut Cursor<&[u8]>)

Source from the content-addressed store, hash-verified

346 }
347
348 async fn read_cstring(&self, cursor: &mut Cursor<&[u8]>) -> Result<String, ParseError> {
349 let mut bytes = Vec::new();
350 loop {
351 if bytes.len() > self.max_string_length {
352 return Err(ParseError::ProtocolViolation("String too long".to_string()));
353 }
354
355 let byte = cursor.read_u8()?;
356 if byte == 0 {
357 break;
358 }
359 bytes.push(byte);
360 }
361
362 String::from_utf8(bytes).map_err(|_| ParseError::InvalidEncoding)
363 }
364
365 async fn read_cstring_with_length(&self, cursor: &mut Cursor<&[u8]>, max_length: usize) -> Result<String, ParseError> {
366 let mut bytes = Vec::new();

Callers 7

parse_startup_messageMethod · 0.80
parse_auth_requestMethod · 0.80
parse_parseMethod · 0.80
parse_bindMethod · 0.80
parse_executeMethod · 0.80
parse_closeMethod · 0.80
parse_describeMethod · 0.80

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected