(buf: &mut BytesMut, elem: Option<&Value>, ty: &Type)
| 952 | } |
| 953 | |
| 954 | fn encode_element(buf: &mut BytesMut, elem: Option<&Value>, ty: &Type) -> Result<(), io::Error> { |
| 955 | match elem { |
| 956 | None => buf.put_i32(-1), |
| 957 | Some(elem) => { |
| 958 | let base = buf.len(); |
| 959 | buf.put_i32(0); |
| 960 | elem.encode_binary(ty, buf)?; |
| 961 | let len = pg_len("encoded element", buf.len() - base - 4)?; |
| 962 | buf[base..base + 4].copy_from_slice(&len.to_be_bytes()); |
| 963 | } |
| 964 | } |
| 965 | Ok(()) |
| 966 | } |
| 967 | |
| 968 | fn pg_len(what: &str, len: usize) -> Result<i32, io::Error> { |
| 969 | len.try_into().map_err(|_| { |
no test coverage detected