#[cfg(feature = "generator")]
use bolero_generator::*;
#[cfg(test)]
use bolero::generator::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(any(feature = "generator", test), derive(TypeGenerator))]
pub enum Constraint {
None,
RetransmissionOnly,
CongestionLimited,
AmplificationLimited,
}
#[test]
fn ordering_test() {
assert!(Constraint::None < Constraint::RetransmissionOnly);
assert!(Constraint::RetransmissionOnly < Constraint::CongestionLimited);
assert!(Constraint::CongestionLimited < Constraint::AmplificationLimited);
}
impl Constraint {
#[inline]
pub fn is_amplification_limited(self) -> bool {
matches!(self, Self::AmplificationLimited)
}
#[inline]
pub fn is_congestion_limited(self) -> bool {
matches!(self, Self::CongestionLimited)
}
#[inline]
pub fn is_retransmission_only(self) -> bool {
matches!(self, Self::RetransmissionOnly)
}
#[inline]
pub fn can_transmit(self) -> bool {
self.is_none()
}
#[inline]
pub fn can_retransmit(self) -> bool {
self.can_transmit() || self.is_retransmission_only()
}
#[inline]
fn is_none(self) -> bool {
matches!(self, Self::None)
}
}