(err: ErrorResponse, dst: &mut BytesMut)
| 307 | } |
| 308 | |
| 309 | fn encode_error_response(err: ErrorResponse, dst: &mut BytesMut) { |
| 310 | dst.put_u8(b'E'); |
| 311 | let len_pos = dst.len(); |
| 312 | dst.put_i32(0); // Placeholder |
| 313 | |
| 314 | // Required fields |
| 315 | dst.put_u8(b'S'); |
| 316 | put_cstring(dst, &err.severity); |
| 317 | |
| 318 | dst.put_u8(b'C'); |
| 319 | put_cstring(dst, &err.code); |
| 320 | |
| 321 | dst.put_u8(b'M'); |
| 322 | put_cstring(dst, &err.message); |
| 323 | |
| 324 | // Optional fields |
| 325 | if let Some(ref detail) = err.detail { |
| 326 | dst.put_u8(b'D'); |
| 327 | put_cstring(dst, detail); |
| 328 | } |
| 329 | |
| 330 | if let Some(ref hint) = err.hint { |
| 331 | dst.put_u8(b'H'); |
| 332 | put_cstring(dst, hint); |
| 333 | } |
| 334 | |
| 335 | if let Some(position) = err.position { |
| 336 | dst.put_u8(b'P'); |
| 337 | put_cstring(dst, &position.to_string()); |
| 338 | } |
| 339 | |
| 340 | // Null terminator |
| 341 | dst.put_u8(0); |
| 342 | |
| 343 | update_message_length(dst, len_pos); |
| 344 | } |
| 345 | |
| 346 | fn encode_notice_response(notice: NoticeResponse, dst: &mut BytesMut) { |
| 347 | dst.put_u8(b'N'); |
no test coverage detected