Serialize the footer to bytes.
(&self)
| 57 | |
| 58 | /// Serialize the footer to bytes. |
| 59 | pub fn to_bytes(&self) -> [u8; FOOTER_SIZE] { |
| 60 | let mut buf = [0u8; FOOTER_SIZE]; |
| 61 | buf[0..4].copy_from_slice(&SEGMENT_MAGIC); |
| 62 | buf[4..6].copy_from_slice(&self.format_version.to_le_bytes()); |
| 63 | buf[6..38].copy_from_slice(&self.created_by); |
| 64 | buf[38..42].copy_from_slice(&self.checksum.to_le_bytes()); |
| 65 | buf[42..50].copy_from_slice(&self.min_lsn.as_u64().to_le_bytes()); |
| 66 | buf[50..58].copy_from_slice(&self.max_lsn.as_u64().to_le_bytes()); |
| 67 | buf |
| 68 | } |
| 69 | |
| 70 | /// Deserialize a footer from bytes. |
| 71 | pub fn from_bytes(buf: &[u8; FOOTER_SIZE]) -> crate::Result<Self> { |