fanring 0.2.1

High-throughput typed MPSC and MPMC channels with per-producer backpressure
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::error::ChannelError;

pub(crate) const fn validate_capacity(capacity: usize, max: usize) -> Result<(), ChannelError> {
    if capacity == 0 {
        return Err(ChannelError::ZeroCapacity);
    }
    if capacity > max {
        return Err(ChannelError::CapacityTooLarge {
            requested: capacity,
            max,
        });
    }
    Ok(())
}