crypto_permutation/io/
util.rs

1//! Utilities for implementing [`Reader`] and [`Writer`].
2
3use super::WriteTooLargeError;
4
5#[cold]
6pub(crate) fn cold() {}
7
8/// Helper function checking that `requested <= capacity` and creating an
9/// appropriate [`WriteTooLargeError`] if this is not the case.
10pub fn check_write_size(requested: usize, capacity: usize) -> Result<(), WriteTooLargeError> {
11    if requested <= capacity {
12        Ok(())
13    } else {
14        Err(WriteTooLargeError {
15            requested,
16            capacity,
17        })
18    }
19}