mod writer

module writer

Structs and Unions

struct ConFrameWriter<W: Write>

A writer that can serialize and write ConFrame objects to any output stream.

This struct encapsulates a writer (like a file) and provides a high-level API for writing simulation frames in the .con format.

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 ConFrameWriter that wraps a given writer.

Arguments

  • writer - Any type that implements std::io::Write, e.g., a File.

fn with_precision(writer: W, precision: usize) -> Self

Creates a new ConFrameWriter with a custom floating-point precision.

Arguments

  • writer - Any type that implements std::io::Write.

  • precision - Number of decimal places for floating-point output.

fn write_frame(&mut self, frame: &ConFrame) -> io::Result<()>

Writes a single ConFrame to the output stream.

impl ConFrameWriter<File>

Functions

fn from_path<P: AsRef<Path>>(path: P) -> io::Result<Self>

Creates a new ConFrameWriter that 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 ConFrameWriter that writes to a file with a custom precision.