use bytemuck::{Pod, Zeroable};
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
#[repr(C)]
pub struct WalEntry {
pub sequence: u64,
pub entry_type: u8,
pub _pad: [u8; 3],
pub payload_len: u32, }
impl WalEntry {
#[must_use]
pub fn new(sequence: u64, entry_type: u8, payload_len: u32) -> Self {
Self {
sequence,
entry_type,
_pad: [0; 3],
payload_len,
}
}
#[must_use]
pub fn as_bytes(&self) -> &[u8; 16] {
bytemuck::cast_ref(self)
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::mem::{align_of, size_of};
#[test]
fn test_wal_entry_layout() {
assert_eq!(size_of::<WalEntry>(), 16);
assert_eq!(align_of::<WalEntry>(), 8);
}
}