foundationdb-rs
foundationdb-rs copied to clipboard
Element:Tuple at depth 0 being encoded as nested tuple
Continuing conversation from #150
Expected behavior:
Element::Tuple(Tuple(vec![
Element::Bytes(vec![0]),
Element::Empty,
Element::Tuple(Tuple(vec![Element::Bytes(vec![0]), Element::Empty])),
])),
&[1, 0, 255, 0, 0, 255, 5, 1, 0, 255, 0, 0, 255, 0],
)
Actual behavior:
Element::Tuple(Tuple(vec![
Element::Bytes(vec![0]),
Element::Empty,
Element::Tuple(Tuple(vec![Element::Bytes(vec![0]), Element::Empty])),
])),
&[5,1, 0, 255, 0, 0, 255, 5, 1, 0, 255, 0, 0, 255, 0, 0],
)
Element::Tuple, Vec<Element> and Tuple encoding/decoding is broken:
- Element::Tuple and Vec<Element> always insert the NESTED and NIL bytes
- Tuple never insert the NESTED and NIL bytes (this type is useless)
- Static rust tuples (T0, ..., TN) are correct and only insert NESTED/NIL if tuple_depth > 0
something I noticed is that when decoding the bytes, it assumes its an Element, and due to that it never goes anywhere else than the first one. Since unlike a Tuple, there's no iteration and because it's returning an offset of just the first decoded element it implodes with Err::InvalidData