pub struct PageData { /* private fields */ }Expand description
Raw page data as an owned byte buffer.
The length always matches the database page size.
Fresh pages stay owned until the first clone, then lazily promote to
Arc<[u8]> for shared copy-on-write snapshots.
Implementations§
Source§impl PageData
impl PageData
Sourcepub fn from_vec(data: Vec<u8>) -> Self
pub fn from_vec(data: Vec<u8>) -> Self
Create from existing bytes. The caller must ensure the length matches the page size.
Create from an already shared immutable page snapshot.
Sourcepub fn image_token(&self) -> u64
pub fn image_token(&self) -> u64
Cheap identity for this exact immutable page image.
Clones preserve the token because they expose identical bytes. Any
mutable access assigns a fresh token before returning the mutable slice,
so caches can key on (page_no, image_token) instead of re-hashing the
whole page to detect page-image changes.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Get the page data as a mutable byte slice.
This performs a clone if the data is shared (Copy-On-Write).
Sourcepub fn is_single_owner_owned(&self) -> bool
pub fn is_single_owner_owned(&self) -> bool
Returns true when this page is backed by single-owner Owned bytes
whose shared-snapshot cache has not yet been materialised.
Callers can use this as a cheap probe before mutating via
as_bytes_mut: a true result guarantees that the subsequent mutable
borrow will NOT trigger a copy-on-write clone (Arc::make_mut) and
thus stays allocation-free.
Sourcepub fn try_zero_extend_owned_to(&mut self, new_len: usize) -> bool
pub fn try_zero_extend_owned_to(&mut self, new_len: usize) -> bool
Extend an owned page buffer with zero bytes in place.
Returns true when the underlying representation stayed owned and was
extended without promoting/cloning through a shared snapshot.