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

Function encode_element

src/pgrepr/src/value.rs:954–966  ·  view source on GitHub ↗
(buf: &mut BytesMut, elem: Option<&Value>, ty: &Type)

Source from the content-addressed store, hash-verified

952}
953
954fn 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
968fn pg_len(what: &str, len: usize) -> Result<i32, io::Error> {
969 len.try_into().map_err(|_| {

Callers 1

encode_binaryMethod · 0.85

Calls 3

pg_lenFunction · 0.85
lenMethod · 0.45
encode_binaryMethod · 0.45

Tested by

no test coverage detected