pub struct IndexPage {
pub blocks: Vec<BlockInfo>,
}Expand description
Serialized array of block metadata records.
An index page contains up to ENTRIES_PER_PAGE (4096) block metadata entries
for a contiguous range of logical blocks. Pages are serialized with bincode
and stored in the snapshot file before the master index.
§Size
- In-memory:
Vec<BlockInfo>(~20 bytes per entry) - Serialized: ~64KB for full page (4096 * 16 bytes)
§Coverage
With 4KB logical blocks, each page covers:
- Logical data: ~16MB (4096 blocks * 4KB)
- Physical data: Depends on compression ratio
§Access Pattern
Pages are loaded on-demand when a read operation requires block metadata:
- Master index binary search identifies page
- Page is read from disk and deserialized
- Page is cached in memory (LRU)
- Block metadata is extracted from page
§Examples
use hexz_core::format::index::{IndexPage, BlockInfo};
let mut page = IndexPage {
blocks: vec![
BlockInfo {
offset: 4096,
length: 2048,
logical_len: 4096,
checksum: 0x12345678,
},
BlockInfo {
offset: 6144,
length: 1024,
logical_len: 4096,
checksum: 0x9ABCDEF0,
},
],
};
// Serialize for storage
let bytes = bincode::serialize(&page).unwrap();
println!("Page size: {} bytes", bytes.len());
// Deserialize on read
let loaded: IndexPage = bincode::deserialize(&bytes).unwrap();
assert_eq!(loaded.blocks.len(), 2);Fields§
§blocks: Vec<BlockInfo>Block metadata entries for this page’s range.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IndexPage
impl<'de> Deserialize<'de> for IndexPage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for IndexPage
impl RefUnwindSafe for IndexPage
impl Send for IndexPage
impl Sync for IndexPage
impl Unpin for IndexPage
impl UnsafeUnpin for IndexPage
impl UnwindSafe for IndexPage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more