Encode a `SparseTile` into `out`. The segment writer wraps this payload in BlockFraming (length + CRC).
(tile: &SparseTile, out: &mut Vec<u8>)
| 58 | /// Encode a `SparseTile` into `out`. The segment writer wraps this payload |
| 59 | /// in BlockFraming (length + CRC). |
| 60 | pub fn encode_sparse_tile(tile: &SparseTile, out: &mut Vec<u8>) -> ArrayResult<()> { |
| 61 | let tag = choose_tag(tile); |
| 62 | out.push(tag.as_byte()); |
| 63 | out.push(PAYLOAD_VERSION); |
| 64 | |
| 65 | match tag { |
| 66 | CodecTag::Raw => encode_raw(tile, out), |
| 67 | CodecTag::Structural => encode_structural(tile, out), |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | fn encode_raw(tile: &SparseTile, out: &mut Vec<u8>) -> ArrayResult<()> { |
| 72 | let bytes = zerompk::to_msgpack_vec(tile).map_err(|e| ArrayError::SegmentCorruption { |