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

Function error_sqlstate

tests/client_compat.rs:1283–1301  ·  view source on GitHub ↗
(message: &RawBackendMessage)

Source from the content-addressed store, hash-verified

1281}
1282
1283fn error_sqlstate(message: &RawBackendMessage) -> Option<String> {
1284 let mut cursor = 0usize;
1285 while cursor < message.body.len() {
1286 let field = message.body[cursor];
1287 cursor += 1;
1288 if field == 0 {
1289 break;
1290 }
1291 let end = message.body[cursor..]
1292 .iter()
1293 .position(|byte| *byte == 0)
1294 .map(|offset| cursor + offset)?;
1295 if field == b'C' {
1296 return Some(String::from_utf8_lossy(&message.body[cursor..end]).into_owned());
1297 }
1298 cursor = end + 1;
1299 }
1300 None
1301}

Callers 1

Calls 2

lenMethod · 0.80
iterMethod · 0.80

Tested by

no test coverage detected