use std::{borrow::Borrow, ops::Deref};
use super::header::RecordHeader;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WalRecord {
pub address: u64,
pub next_address: u64,
pub header: RecordHeader,
pub payload: Vec<u8>,
}
impl Deref for WalRecord {
type Target = [u8];
#[inline]
fn deref(&self) -> &Self::Target {
&self.payload
}
}
impl AsRef<[u8]> for WalRecord {
#[inline]
fn as_ref(&self) -> &[u8] {
&self.payload
}
}
impl Borrow<[u8]> for WalRecord {
#[inline]
fn borrow(&self) -> &[u8] {
&self.payload
}
}
impl WalRecord {
#[inline]
pub fn as_slice(&self) -> &[u8] {
&self.payload
}
#[inline]
pub fn into_payload(self) -> Vec<u8> {
self.payload
}
#[inline]
pub fn len(&self) -> usize {
self.payload.len()
}
#[inline]
pub fn is_empty(&self) -> bool {
self.payload.is_empty()
}
}