wave_stream/
assertions.rs

1use std::io::{Error, ErrorKind, Result};
2
3use crate::constants::{MAX_INT_24, MIN_INT_24};
4
5// Asserts that the value is a valid 24-bit int
6// (Because rust doesn't support 24-bit ints, they are put into 32-bit ints)
7pub fn assert_int_24(v: i32) -> Result<()> {
8    if v < MIN_INT_24 || v > MAX_INT_24 {
9        return Result::Err(Error::new(
10            ErrorKind::InvalidData,
11            "Value must be a valid 24-bit integer",
12        ));
13    }
14
15    Ok(())
16}