Skip to main content

Mf4Writer

Struct Mf4Writer 

Source
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

Source

pub fn new() -> Self

A new, empty file, stamped with the current time as its start time.

Source

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.

Source

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.

Source

pub fn set_codec(&mut self, codec: WriteCodec)

Sets the compression codec to use when compression is enabled.

Source

pub fn codec(&self) -> WriteCodec

Returns the configured compression codec.

Source

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.

Source

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.

Source

pub fn start_time_ns(&self) -> i64

Returns the start time of the measurement in nanoseconds since the Unix epoch.

Source

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.

Source

pub fn is_compressed(&self) -> bool

Returns true if data blocks are configured to be deflated.

Source

pub fn groups(&self) -> &[WriteGroup]

Returns an immutable slice of channel groups in the file.

Source

pub fn groups_mut(&mut self) -> &mut [WriteGroup]

Returns a mutable slice of channel groups in the file.

Source

pub fn group(&self, index: usize) -> Option<&WriteGroup>

Returns a reference to the group at index, or None if out of bounds.

Source

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.

Source

pub fn remove_group(&mut self, index: usize) -> WriteGroup

Removes and returns the group at index.

Source

pub fn retain_groups<F: FnMut(&WriteGroup) -> bool>(&mut self, f: F)

Retains only the groups specified by the predicate.

Source

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.

Source

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.

Source

pub fn write<W: Write>(&self, out: &mut W) -> Result<()>

Writes the file to out.

Source

pub fn write_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

Writes the file to a path, creating or truncating it.

Trait Implementations§

Source§

impl Debug for Mf4Writer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Mf4Writer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.