Create a new footer for a segment.
(created_by: &str, checksum: u32, min_lsn: Lsn, max_lsn: Lsn)
| 41 | impl SegmentFooter { |
| 42 | /// Create a new footer for a segment. |
| 43 | pub fn new(created_by: &str, checksum: u32, min_lsn: Lsn, max_lsn: Lsn) -> Self { |
| 44 | let mut cb = [0u8; 32]; |
| 45 | let bytes = created_by.as_bytes(); |
| 46 | let len = bytes.len().min(32); |
| 47 | cb[..len].copy_from_slice(&bytes[..len]); |
| 48 | |
| 49 | Self { |
| 50 | format_version: FORMAT_VERSION, |
| 51 | created_by: cb, |
| 52 | checksum, |
| 53 | min_lsn, |
| 54 | max_lsn, |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /// Serialize the footer to bytes. |
| 59 | pub fn to_bytes(&self) -> [u8; FOOTER_SIZE] { |