Skip to main content

bytes_per_frame

Function bytes_per_frame 

Source
pub fn bytes_per_frame(
    datatype: &Datatype,
    channel_count: usize,
) -> Result<usize, SigmfError>
Expand description

Returns the size in bytes of one frame of channel_count channels.

§Errors

Returns SigmfError::InvalidMetadata if channel_count is zero or the size overflows.

§Examples

use sigmf::datatype::Datatype;
use sigmf::utils::data::{bytes_per_frame, frame_count};
use std::str::FromStr;

let datatype = Datatype::from_str("cf32_le")?;
assert_eq!(bytes_per_frame(&datatype, 4)?, 32);
assert_eq!(frame_count(320, &datatype, 4)?, 10);
assert!(frame_count(321, &datatype, 4).is_err());