pub struct PageSlab {
pub size: u64,
pub pages: Vec<PageSlot>,
}Expand description
The dense immutable backing of a DataCap: a custom runtime-sized SSZ
vector of pages.
pages[i] is absolute page i; trailing PageSlot::Empty pages may be
omitted (so pages.len() <= page_count), and an out-of-range index reads as
Empty (zero) — the merkle pads them back via the zero-hash table. The
hash_tree_root is merkleize(page_roots, page_count) at runtime depth.
Fields§
§size: u64Logical byte length; always a PAGE_SIZE multiple. page_count = size / PAGE_SIZE.
pages: Vec<PageSlot>Dense page storage indexed by absolute page (trailing Empty trimmed).
Implementations§
Source§impl PageSlab
impl PageSlab
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Number of logical pages (size / PAGE_SIZE).
Sourcepub fn page(&self, i: usize) -> &PageSlot
pub fn page(&self, i: usize) -> &PageSlot
Borrow page i (absolute). Out-of-range / trimmed-tail reads as
PageSlot::Empty.
Sourcepub fn from_sparse_pages<'a>(
size: u64,
pages: impl IntoIterator<Item = (u32, &'a [u8])>,
) -> Self
pub fn from_sparse_pages<'a>( size: u64, pages: impl IntoIterator<Item = (u32, &'a [u8])>, ) -> Self
Build a slab of logical size (a PAGE_SIZE multiple) from sparse
named pages: pages yields (page_index, content) for the non-zero
pages (content ≤ PAGE_SIZE); every unnamed page is the canonical
zero page. Reuses put_page_idx so the result is the same canonical
form (all-zero → Empty, trailing Empty trimmed) a contiguous
from_bytes_sized build would produce — i.e. byte- and hash-identical
for equivalent logical content. The decode target for
crate::image::DataDesc.
Trait Implementations§
Source§impl Archive for PageSlab
impl Archive for PageSlab
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedPageSlab
type Archived = ArchivedPageSlab
Source§type Resolver = PageSlabResolver
type Resolver = PageSlabResolver
Auto Trait Implementations§
impl Freeze for PageSlab
impl RefUnwindSafe for PageSlab
impl Send for PageSlab
impl Sync for PageSlab
impl Unpin for PageSlab
impl UnsafeUnpin for PageSlab
impl UnwindSafe for PageSlab
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read more