pub struct Checkpoint {
pub version: u32,
pub timestamp: u64,
pub step: u64,
pub sim_time: f64,
pub state: Vec<u8>,
pub checksum: u32,
}Expand description
A single simulation snapshot with version, timestamp, and raw state bytes.
Checkpoint is a self-contained snapshot that can be serialized to bytes,
compared with CheckpointDiff, or stored in a CheckpointCatalog.
Fields§
§version: u32Monotonically increasing version counter for this checkpoint sequence.
timestamp: u64Unix timestamp (seconds since epoch) when this checkpoint was taken.
step: u64Simulation step number.
sim_time: f64Simulation time in seconds or simulation units.
state: Vec<u8>Arbitrary raw simulation state bytes.
checksum: u32CRC-32 checksum of state (set by Checkpoint::compute_checksum).
Implementations§
Source§impl Checkpoint
impl Checkpoint
Sourcepub fn new(
version: u32,
timestamp: u64,
step: u64,
sim_time: f64,
state: Vec<u8>,
) -> Self
pub fn new( version: u32, timestamp: u64, step: u64, sim_time: f64, state: Vec<u8>, ) -> Self
Construct a new Checkpoint, computing the checksum automatically.
Sourcepub fn compute_checksum(&mut self)
pub fn compute_checksum(&mut self)
Recompute and store the checksum from the current state.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize this checkpoint to a flat byte buffer.
Layout:
- 4 bytes: version (LE u32)
- 8 bytes: timestamp (LE u64)
- 8 bytes: step (LE u64)
- 8 bytes: sim_time (LE f64 bits)
- 4 bytes: checksum (LE u32)
- 8 bytes: state length (LE u64)
- N bytes: state data
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize a Checkpoint from a byte slice.
Trait Implementations§
Source§impl Clone for Checkpoint
impl Clone for Checkpoint
Source§fn clone(&self) -> Checkpoint
fn clone(&self) -> Checkpoint
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Checkpoint
impl Debug for Checkpoint
Source§impl PartialEq for Checkpoint
impl PartialEq for Checkpoint
Source§fn eq(&self, other: &Checkpoint) -> bool
fn eq(&self, other: &Checkpoint) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Checkpoint
Auto Trait Implementations§
impl Freeze for Checkpoint
impl RefUnwindSafe for Checkpoint
impl Send for Checkpoint
impl Sync for Checkpoint
impl Unpin for Checkpoint
impl UnsafeUnpin for Checkpoint
impl UnwindSafe for Checkpoint
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.