pub struct SegmentPreamble {
pub magic: [u8; 4],
pub version: u16,
pub cipher_alg: u8,
pub kid: u8,
pub epoch: [u8; 4],
}Expand description
Preamble written at offset 0 of every segment file (WAL or storage).
Fields§
§magic: [u8; 4]File-type magic: WAL_PREAMBLE_MAGIC or SEG_PREAMBLE_MAGIC.
version: u16Layout version (must equal PREAMBLE_VERSION).
cipher_alg: u8Cipher algorithm: 0 = AES-256-GCM.
kid: u8Key ID within the active key ring (0 = current KEK).
epoch: [u8; 4]Random epoch generated at WAL-lifetime start; used as the high 4 bytes of every AES-GCM nonce in this segment.
Implementations§
Source§impl SegmentPreamble
impl SegmentPreamble
Sourcepub fn to_bytes(&self) -> [u8; 16]
pub fn to_bytes(&self) -> [u8; 16]
Serialize to exactly PREAMBLE_SIZE bytes.
Sourcepub fn from_bytes(buf: &[u8; 16], expected_magic: &[u8; 4]) -> Result<Self>
pub fn from_bytes(buf: &[u8; 16], expected_magic: &[u8; 4]) -> Result<Self>
Deserialize and validate a preamble, checking magic and version.
expected_magic must be either WAL_PREAMBLE_MAGIC or
SEG_PREAMBLE_MAGIC.
Trait Implementations§
Source§impl Clone for SegmentPreamble
impl Clone for SegmentPreamble
Source§fn clone(&self) -> SegmentPreamble
fn clone(&self) -> SegmentPreamble
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SegmentPreamble
impl Debug for SegmentPreamble
Source§impl PartialEq for SegmentPreamble
impl PartialEq for SegmentPreamble
Source§fn eq(&self, other: &SegmentPreamble) -> bool
fn eq(&self, other: &SegmentPreamble) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for SegmentPreamble
impl Eq for SegmentPreamble
impl StructuralPartialEq for SegmentPreamble
Auto Trait Implementations§
impl Freeze for SegmentPreamble
impl RefUnwindSafe for SegmentPreamble
impl Send for SegmentPreamble
impl Sync for SegmentPreamble
impl Unpin for SegmentPreamble
impl UnsafeUnpin for SegmentPreamble
impl UnwindSafe for SegmentPreamble
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