Skip to main content

encode

Function encode 

Source
pub fn encode(
    samples: &[SampleValue],
    datatype: &Datatype,
    channel_count: usize,
) -> Result<Vec<u8>, SigmfError>
Expand description

Encodes complete frames of samples into raw bytes.

samples is in on-disk order (see the module documentation) and its length must be a multiple of channel_count. Every sample must use the SampleValue variant matching datatype.

ยงErrors

Returns SigmfError::InvalidMetadata if channel_count is zero or the samples do not form complete frames, SigmfError::InvalidDataType if a sample does not match datatype, or SigmfError::ResourceLimit if the encoded size overflows.