use std::num::NonZeroUsize;
use crate::transport_stream::TS_PACKET_SIZE;
use crate::{Error, Result};
pub(super) fn capacity(capacity: NonZeroUsize) -> Result<usize> {
let bytes = capacity.get();
if bytes % TS_PACKET_SIZE != 0 {
return Err(Error::InvalidArgument {
field: "capacity_bytes",
message: "must be a multiple of 188 bytes".to_owned(),
});
}
Ok(bytes)
}
pub(super) fn packets(data: &[u8]) -> Result<()> {
if data.len() % TS_PACKET_SIZE == 0 {
Ok(())
} else {
Err(Error::InvalidArgument {
field: "data",
message: "must be a multiple of 188 bytes".to_owned(),
})
}
}