foundationdb-rs icon indicating copy to clipboard operation
foundationdb-rs copied to clipboard

Element:Tuple at depth 0 being encoded as nested tuple

Open Aioxas opened this issue 5 years ago • 2 comments

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],
        )

Aioxas avatar Nov 26 '19 22:11 Aioxas

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

Speedy37 avatar Nov 26 '19 23:11 Speedy37

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

Aioxas avatar Nov 29 '19 22:11 Aioxas