pub struct KernelSnapshot { /* private fields */ }Expand description
Opaque point-in-time snapshot of kernel state.
Pub struct, pub(crate) fields — external callers see the type at the
API boundary and can hold a value, but cannot inspect its internals
(use serialize / deserialize
for round-trip persistence). Fed to
Kernel::from_snapshot for restore.
Implementations§
Source§impl KernelSnapshot
impl KernelSnapshot
Sourcepub fn deserialize(bytes: &[u8]) -> Result<Self, SnapshotError>
pub fn deserialize(bytes: &[u8]) -> Result<Self, SnapshotError>
Decode from canonical postcard bytes.
After decoding, structural invariants are validated (currently the
scheduler three-table index consistency of every captured instance)
so a corrupt or tampered snapshot is rejected here rather than
triggering a latent panic during a later replay/step. This trusts
the provenance of the bytes — for an untrusted source, gate them
through deserialize_verified first.
Sourcepub fn deserialize_verified(
bytes: &[u8],
expected_digest: &[u8; 32],
) -> Result<Self, SnapshotError>
pub fn deserialize_verified( bytes: &[u8], expected_digest: &[u8; 32], ) -> Result<Self, SnapshotError>
Decode from canonical postcard bytes, first verifying their
integrity against a caller-supplied BLAKE3 digest obtained
out-of-band (recorded when the snapshot was taken, or distributed
over a trusted channel). Use this for snapshots from an untrusted
source: it closes the gap whereby deserialize
alone trusts whatever bytes it is handed. The kernel supplies the
mechanism (digest comparison); the caller owns the policy of
which digest to trust.
Sourcepub fn digest(bytes: &[u8]) -> [u8; 32]
pub fn digest(bytes: &[u8]) -> [u8; 32]
BLAKE3 digest of a snapshot’s canonical bytes — the value a caller
records out-of-band to later verify integrity via
deserialize_verified.
Sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
Number of instances captured.
Sourcepub fn instance_ids(&self) -> impl Iterator<Item = InstanceId> + '_
pub fn instance_ids(&self) -> impl Iterator<Item = InstanceId> + '_
Iterate captured instance ids in canonical (InstanceId ascending) order.
Trait Implementations§
Source§impl Clone for KernelSnapshot
impl Clone for KernelSnapshot
Source§fn clone(&self) -> KernelSnapshot
fn clone(&self) -> KernelSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more