pub struct Checkpoint {
pub header: CheckpointHeader,
pub metadata: CheckpointMetadata,
pub chunks: Vec<DataChunk>,
}Expand description
Complete checkpoint containing all kernel state.
Fields§
§header: CheckpointHeaderCheckpoint header.
metadata: CheckpointMetadataKernel metadata.
chunks: Vec<DataChunk>Data chunks.
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn new(metadata: CheckpointMetadata) -> Self
pub fn new(metadata: CheckpointMetadata) -> Self
Create a new checkpoint.
Sourcepub fn add_control_block(&mut self, data: Vec<u8>)
pub fn add_control_block(&mut self, data: Vec<u8>)
Add control block data.
Sourcepub fn add_h2k_queue(&mut self, data: Vec<u8>)
pub fn add_h2k_queue(&mut self, data: Vec<u8>)
Add H2K queue data.
Sourcepub fn add_k2h_queue(&mut self, data: Vec<u8>)
pub fn add_k2h_queue(&mut self, data: Vec<u8>)
Add K2H queue data.
Sourcepub fn add_hlc_state(&mut self, data: Vec<u8>)
pub fn add_hlc_state(&mut self, data: Vec<u8>)
Add HLC state.
Sourcepub fn add_device_memory(&mut self, name: &str, data: Vec<u8>)
pub fn add_device_memory(&mut self, name: &str, data: Vec<u8>)
Add device memory region.
Sourcepub fn get_chunks(&self, chunk_type: ChunkType) -> Vec<&DataChunk>
pub fn get_chunks(&self, chunk_type: ChunkType) -> Vec<&DataChunk>
Get all chunks of a type.
Sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Calculate total size in bytes.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserialize checkpoint from bytes.
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn content_digest(&self) -> String
pub fn content_digest(&self) -> String
Stable content digest of the checkpoint’s data chunks.
This is a CRC32 over each chunk’s (identity, data) in the order
they were added. Two checkpoints with the same content digest
have identical chunk contents at identical identities. Used as
the stable “parent id” for delta checkpoints.
Sourcepub fn delta_from(base: &Checkpoint, new: &Checkpoint) -> Checkpoint
pub fn delta_from(base: &Checkpoint, new: &Checkpoint) -> Checkpoint
Produce a delta checkpoint: chunks present in new whose bytes
differ from the corresponding chunk in base (same identity),
plus chunks that are new in new. Unchanged chunks are omitted.
The delta’s metadata.custom records the base’s content digest
under DELTA_PARENT_DIGEST_KEY so the reader can verify it
before applying.
Restore via Checkpoint::applied_with_delta.
Sourcepub fn applied_with_delta(
base: &Checkpoint,
delta: &Checkpoint,
) -> Result<Checkpoint>
pub fn applied_with_delta( base: &Checkpoint, delta: &Checkpoint, ) -> Result<Checkpoint>
Apply a delta produced by Checkpoint::delta_from on top of
base, returning the resulting full checkpoint. Chunks in the
delta replace chunks with the same identity in base; chunks
only in base carry over unchanged.
Errors if the delta’s recorded parent digest does not match
base.content_digest() — this catches accidental application
on top of the wrong base.
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§fn clone(&self) -> Checkpoint
fn clone(&self) -> Checkpoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more