pub struct WalRecord {
pub header: RecordHeader,
pub payload: Vec<u8>,
}Expand description
A complete WAL record: header + payload.
Fields§
§header: RecordHeader§payload: Vec<u8>Implementations§
Source§impl WalRecord
impl WalRecord
Sourcepub fn new(
record_type: u16,
lsn: u64,
tenant_id: u32,
vshard_id: u16,
payload: Vec<u8>,
encryption_key: Option<&WalEncryptionKey>,
) -> Result<Self>
pub fn new( record_type: u16, lsn: u64, tenant_id: u32, vshard_id: u16, payload: Vec<u8>, encryption_key: Option<&WalEncryptionKey>, ) -> Result<Self>
Create a new WAL record with computed CRC32C.
If encryption_key is provided, the payload is encrypted before
CRC computation. The ciphertext includes a 16-byte auth tag.
Sourcepub fn decrypt_payload(
&self,
encryption_key: Option<&WalEncryptionKey>,
) -> Result<Vec<u8>>
pub fn decrypt_payload( &self, encryption_key: Option<&WalEncryptionKey>, ) -> Result<Vec<u8>>
Decrypt the payload if the record is encrypted.
Returns the plaintext payload. If not encrypted, returns the payload as-is.
Sourcepub fn decrypt_payload_ring(&self, ring: Option<&KeyRing>) -> Result<Vec<u8>>
pub fn decrypt_payload_ring(&self, ring: Option<&KeyRing>) -> Result<Vec<u8>>
Decrypt the payload using a key ring (supports dual-key rotation).
Tries the current key first, then falls back to the previous key. Returns the plaintext payload. If not encrypted, returns the payload as-is.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Whether this record’s payload is encrypted.
Sourcepub fn logical_record_type(&self) -> u16
pub fn logical_record_type(&self) -> u16
Get the logical record type (with encryption flag stripped).
Sourcepub fn verify_checksum(&self) -> Result<()>
pub fn verify_checksum(&self) -> Result<()>
Verify the CRC32C checksum.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WalRecord
impl RefUnwindSafe for WalRecord
impl Send for WalRecord
impl Sync for WalRecord
impl Unpin for WalRecord
impl UnsafeUnpin for WalRecord
impl UnwindSafe for WalRecord
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more