Struct ConFrameWriter

Source
pub struct ConFrameWriter<W: Write> { /* private fields */ }
Expand description

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

let mut writer = ConFrameWriter::from_path("output.con").unwrap();
writer.extend(frames.iter()).unwrap();

Implementations§

Source§

impl<W: Write> ConFrameWriter<W>

Source

pub 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.
Source

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

Writes a single ConFrame to the output stream.

Source

pub fn extend<'a>( &mut self, frames: impl Iterator<Item = &'a ConFrame>, ) -> Result<()>

Writes all frames from an iterator to the output stream.

This is the most convenient way to write a multi-frame file.

Source§

impl ConFrameWriter<File>

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> 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.

Auto Trait Implementations§

§

impl<W> Freeze for ConFrameWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for ConFrameWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for ConFrameWriter<W>
where W: Send,

§

impl<W> Sync for ConFrameWriter<W>
where W: Sync,

§

impl<W> Unpin for ConFrameWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for ConFrameWriter<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.