pub struct CheckpointWriter {
pub path: PathBuf,
pub compress: bool,
}Expand description
Writes simulation snapshots to a binary checkpoint file.
Call methods in order:
write_header(CheckpointWriter::write_header)write_positions(optional)write_velocities(optional)- Any number of
write_scalars/write_integers finalize
Fields§
§path: PathBufDestination file path.
compress: boolWhether to Zstandard-compress the file after finalize.
Implementations§
Source§impl CheckpointWriter
impl CheckpointWriter
Sourcepub fn with_compress(self, compress: bool) -> Self
pub fn with_compress(self, compress: bool) -> Self
Enable or disable Zstandard compression of the finalised file.
Sourcepub fn write_header(&self, meta: &CheckpointMetadata) -> Result<()>
pub fn write_header(&self, meta: &CheckpointMetadata) -> Result<()>
Write the file header and metadata record.
Creates (or truncates) the file and writes the magic number, format version, and serialized metadata.
Sourcepub fn write_positions(&self, pos: &[[f64; 3]]) -> Result<()>
pub fn write_positions(&self, pos: &[[f64; 3]]) -> Result<()>
Append a positions block ([[f64; 3\]]) to the checkpoint file.
Each position is written as three little-endian f64 values.
Sourcepub fn write_velocities(&self, vel: &[[f64; 3]]) -> Result<()>
pub fn write_velocities(&self, vel: &[[f64; 3]]) -> Result<()>
Append a velocities block ([[f64; 3\]]) to the checkpoint file.
Sourcepub fn write_scalars(&self, name: &str, data: &[f64]) -> Result<()>
pub fn write_scalars(&self, name: &str, data: &[f64]) -> Result<()>
Append a named scalar (f64) array to the checkpoint file.
Sourcepub fn write_integers(&self, name: &str, data: &[i32]) -> Result<()>
pub fn write_integers(&self, name: &str, data: &[i32]) -> Result<()>
Append a named integer (i32) array to the checkpoint file.
Sourcepub fn finalize(&self) -> Result<()>
pub fn finalize(&self) -> Result<()>
Write the footer record containing the file checksum, then optionally compress the entire file in-place with Zstandard.
Reads back the entire file written so far, computes the checksum, and
appends a footer tag followed by the 4-byte checksum. If
with_compress was set to true,
the finalized file is replaced with its Zstandard-compressed equivalent.
Trait Implementations§
Source§impl Clone for CheckpointWriter
impl Clone for CheckpointWriter
Source§fn clone(&self) -> CheckpointWriter
fn clone(&self) -> CheckpointWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CheckpointWriter
impl RefUnwindSafe for CheckpointWriter
impl Send for CheckpointWriter
impl Sync for CheckpointWriter
impl Unpin for CheckpointWriter
impl UnsafeUnpin for CheckpointWriter
impl UnwindSafe for CheckpointWriter
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
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.