pub struct Superblock {Show 19 fields
pub format_version: u32,
pub min_reader_version: u32,
pub page_size: u32,
pub shard_count: u32,
pub seq: u64,
pub file_size: u64,
pub file_uuid: [u8; 16],
pub created_unix_ms: u64,
pub checkpoint_unix_ms: u64,
pub db_count: u32,
pub flags: u32,
pub replid_hi: u64,
pub replid_lo: u64,
pub replid_ext: u32,
pub shard_table_off: u32,
pub shard_table_len: u16,
pub catalog_addr: u64,
pub free_list_addr: u64,
pub archival_root: u64,
}Expand description
The header half of a superblock slot, decoded.
The shard table and the checkpoint entries are not in here on purpose. They are variable length, they live further into the same 16 KiB, and a caller that only wants to know the page size should not pay to decode 16384 slot assignments to find out.
Fields§
§format_version: u32The format this slot was written by.
min_reader_version: u32The lowest reader version that may read it.
page_size: u32Segment size, fixed at creation.
shard_count: u32Shard count, fixed at creation.
seq: u64Monotonic. The higher of the two valid slots wins.
file_size: u64Segments times page_size plus DATA_START.
file_uuid: [u8; 16]Identifies this database across copies of the file.
created_unix_ms: u64When the file was created.
checkpoint_unix_ms: u64When this checkpoint was taken.
db_count: u32Logical databases, default 16.
flags: u32See superblock_flags.
replid_hi: u64The replication id, high 64 bits of the 40 hex characters.
replid_lo: u64The replication id, next 64 bits.
replid_ext: u32The replication id, last 32 bits.
shard_table_off: u32Offset within the slot of the run length encoded shard table.
shard_table_len: u16Length in bytes of that encoding.
catalog_addr: u64Address of the collection catalogue, or 0 if there are no collections.
free_list_addr: u64Address of the free segment list.
archival_root: u64Address of the archival root, or 0.
Implementations§
Source§impl Superblock
impl Superblock
Sourcepub fn encode(&self, slot: &mut [u8])
pub fn encode(&self, slot: &mut [u8])
Writes the header fields into the first 160 bytes of slot.
Leaves the checksum alone, because the bytes it covers have not all been
written yet. Call seal once the table and the entries are in.
§Panics
If slot is not exactly SUPERBLOCK_LEN bytes. That is a programmer
error rather than a corrupt file, so it is not an Err.
Sourcepub fn decode(slot: &[u8]) -> Result<Superblock>
pub fn decode(slot: &[u8]) -> Result<Superblock>
Reads the header fields, checking everything that makes the file ours.
In order: the length, the magic, the checksum, then the version. The checksum comes before the version check so that a corrupt slot is reported as corrupt rather than as a version from the future, which is what happens if a flipped bit lands in the version field.
Sourcepub const fn checkpoint_off(&self) -> usize
pub const fn checkpoint_off(&self) -> usize
Where the checkpoint entries begin, which is right after the table.
Sourcepub fn checkpoints_fit(&self) -> bool
pub fn checkpoints_fit(&self) -> bool
Whether every checkpoint entry fits inside the slot.
A file whose shard count and table length do not leave room for the entries is corrupt in a way that would otherwise show up as a checkpoint full of zeroes, which reads as a valid empty database.
Trait Implementations§
Source§impl Clone for Superblock
impl Clone for Superblock
Source§fn clone(&self) -> Superblock
fn clone(&self) -> Superblock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more