pub struct Mf4Writer { /* private fields */ }Expand description
An MF4 file under construction.
Channel groups can each have their own data group (via Mf4Writer::add_group)
or share a data group with sibling groups (via Mf4Writer::add_group_in),
with their records sorted by time.
Implementations§
Source§impl Mf4Writer
impl Mf4Writer
Sourcepub fn with_start_time_ns(start_time_ns: i64) -> Self
pub fn with_start_time_ns(start_time_ns: i64) -> Self
A new, empty file with an explicit start time, in nanoseconds since the Unix epoch. Deterministic output for tests, and for re-exporting a file under its original timestamp.
Sourcepub fn set_compression(&mut self, on: bool)
pub fn set_compression(&mut self, on: bool)
Whether to deflate each group’s records into a ##DZ block.
Off by default. Compression costs write time and makes the file opaque to anything that reads bytes rather than blocks; it is worth it for the long, slowly-varying channels a logger produces, and rarely worth it for a handful of samples.
Sourcepub fn set_codec(&mut self, codec: WriteCodec)
pub fn set_codec(&mut self, codec: WriteCodec)
Sets the compression codec to use when compression is enabled.
Sourcepub fn codec(&self) -> WriteCodec
pub fn codec(&self) -> WriteCodec
Returns the configured compression codec.
Sourcepub fn add_group(&mut self, times: &[f64]) -> Result<&mut WriteGroup>
pub fn add_group(&mut self, times: &[f64]) -> Result<&mut WriteGroup>
Adds a channel group sampled at times (seconds). The records are
sorted by time on write, so times need not be ordered — but every
timestamp must be orderable, and NaN is not.
Sourcepub fn add_group_in(
&mut self,
sibling: usize,
times: &[f64],
) -> Result<&mut WriteGroup>
pub fn add_group_in( &mut self, sibling: usize, times: &[f64], ) -> Result<&mut WriteGroup>
Adds a channel group that shares a data group with sibling, so their
records interleave behind a record ID.
Sourcepub fn start_time_ns(&self) -> i64
pub fn start_time_ns(&self) -> i64
Returns the start time of the measurement in nanoseconds since the Unix epoch.
Sourcepub fn set_start_time_ns(&mut self, start_time_ns: i64)
pub fn set_start_time_ns(&mut self, start_time_ns: i64)
Sets the start time of the measurement in nanoseconds since the Unix epoch.
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Returns true if data blocks are configured to be deflated.
Sourcepub fn groups(&self) -> &[WriteGroup]
pub fn groups(&self) -> &[WriteGroup]
Returns an immutable slice of channel groups in the file.
Sourcepub fn groups_mut(&mut self) -> &mut [WriteGroup]
pub fn groups_mut(&mut self) -> &mut [WriteGroup]
Returns a mutable slice of channel groups in the file.
Sourcepub fn group(&self, index: usize) -> Option<&WriteGroup>
pub fn group(&self, index: usize) -> Option<&WriteGroup>
Returns a reference to the group at index, or None if out of bounds.
Sourcepub fn group_mut(&mut self, index: usize) -> Option<&mut WriteGroup>
pub fn group_mut(&mut self, index: usize) -> Option<&mut WriteGroup>
Returns a mutable reference to the group at index, or None if out of bounds.
Sourcepub fn remove_group(&mut self, index: usize) -> WriteGroup
pub fn remove_group(&mut self, index: usize) -> WriteGroup
Removes and returns the group at index.
Sourcepub fn retain_groups<F: FnMut(&WriteGroup) -> bool>(&mut self, f: F)
pub fn retain_groups<F: FnMut(&WriteGroup) -> bool>(&mut self, f: F)
Retains only the groups specified by the predicate.
Sourcepub fn from_file(file: &Mf4File) -> Result<Self>
pub fn from_file(file: &Mf4File) -> Result<Self>
Imports editable data, logging every omission. Use
Self::from_file_with_report for a machine-readable report or strict
preservation. An unusable present master is never replaced by indices.
Sourcepub fn from_file_with_report(
file: &Mf4File,
mode: RewriteMode,
) -> Result<(Self, RewriteReport)>
pub fn from_file_with_report( file: &Mf4File, mode: RewriteMode, ) -> Result<(Self, RewriteReport)>
Imports supported typed data, raw conversions, units and invalidation, reporting every omitted channel and metadata item. Strict mode returns an error if the report is nonempty, so callers cannot accidentally save a partially preserved file. No output file is created by this method.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mf4Writer
impl RefUnwindSafe for Mf4Writer
impl Send for Mf4Writer
impl Sync for Mf4Writer
impl Unpin for Mf4Writer
impl UnsafeUnpin for Mf4Writer
impl UnwindSafe for Mf4Writer
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more