mod writer¶
- module writer¶
Structs and Unions
- struct ConFrameWriter<W: Write>¶
A writer that can serialize and write
ConFrameobjects to any output stream.This struct encapsulates a writer (like a file) and provides a high-level API for writing simulation frames in the
.conformat.Example .. code-block:: no_run
use std::fs::File; use readcon_core::types::ConFrame; use readcon_core::writer::ConFrameWriter; let frames: Vec<ConFrame> = Vec::new(); let mut writer = ConFrameWriter::from_path(“output.con”).unwrap(); writer.extend(frames.iter()).unwrap();
Implementations
- impl<W: Write> ConFrameWriter<W>¶
Functions
- fn extend<'a>(&mut self, frames: impl Iterator<Item = &'a ConFrame>) -> io::Result<()>¶
Writes all frames from an iterator to the output stream.
This is the most convenient way to write a multi-frame file.
- fn new(writer: W) -> Self¶
Creates a new
ConFrameWriterthat wraps a given writer.Arguments
writer- Any type that implementsstd::io::Write, e.g., aFile.
- fn with_precision(writer: W, precision: usize) -> Self¶
Creates a new
ConFrameWriterwith a custom floating-point precision.Arguments
writer- Any type that implementsstd::io::Write.precision- Number of decimal places for floating-point output.
- impl ConFrameWriter<File>¶
Functions
- fn from_path<P: AsRef<Path>>(path: P) -> io::Result<Self>¶
Creates a new
ConFrameWriterthat writes to a file at the given path.This is a convenience function that creates the file and wraps it.
- fn from_path_with_precision<P: AsRef<Path>>(path: P, precision: usize) -> io::Result<Self>¶
Creates a new
ConFrameWriterthat writes to a file with a custom precision.