Write the header to `out`, appending CRC32C of the preceding 28 bytes. Returns the total bytes written (always [`HEADER_SIZE`]).
(&self, out: &mut Vec<u8>)
| 46 | /// Write the header to `out`, appending CRC32C of the preceding 28 |
| 47 | /// bytes. Returns the total bytes written (always [`HEADER_SIZE`]). |
| 48 | pub fn encode_to(&self, out: &mut Vec<u8>) -> usize { |
| 49 | let start = out.len(); |
| 50 | out.extend_from_slice(&HEADER_MAGIC); |
| 51 | out.extend_from_slice(&self.version.to_le_bytes()); |
| 52 | out.extend_from_slice(&self.flags.to_le_bytes()); |
| 53 | out.extend_from_slice(&self.schema_hash.to_le_bytes()); |
| 54 | let crc = crc32c::crc32c(&out[start..start + 20]); |
| 55 | out.extend_from_slice(&crc.to_le_bytes()); |
| 56 | HEADER_SIZE |
| 57 | } |
| 58 | |
| 59 | pub fn decode(bytes: &[u8]) -> ArrayResult<Self> { |
| 60 | if bytes.len() < HEADER_SIZE { |