Skip to main content

PageData

Struct PageData 

Source
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

Source

pub fn zeroed(size: PageSize) -> Self

Create a zero-filled page of the given size.

Source

pub fn from_vec(data: Vec<u8>) -> Self

Create from existing bytes. The caller must ensure the length matches the page size.

Source

pub fn from_shared(bytes: Arc<[u8]>) -> Self

Create from an already shared immutable page snapshot.

Source

pub fn as_bytes(&self) -> &[u8]

Get the page data as a byte slice.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Get the length in bytes.

Source

pub fn is_empty(&self) -> bool

Returns true if the page data is empty (should never be true for valid pages).

Source

pub fn into_vec(self) -> Vec<u8>

Consume self and return the inner Vec<u8>.

If the data is shared, this clones into a new Vec.

Trait Implementations§

Source§

impl AsMut<[u8]> for PageData

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for PageData

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for PageData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PageData

Source§

impl PartialEq for PageData

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more