pub struct Range {
pub min: Option<f64>,
pub max: Option<f64>,
pub min_inclusive: bool,
pub max_inclusive: bool,
}Expand description
Numeric range constraint.
Precision Warning: Bounds are stored as f64. Integers larger than 2^53
(9,007,199,254,740,992) will lose precision.
For Snowflake IDs or 64-bit integers: Use String comparison or Exact matching
to avoid precision loss. Do NOT use Range for IDs > 2^53.
Wire type ID: 3
Fields§
§min: Option<f64>§max: Option<f64>§min_inclusive: bool§max_inclusive: boolImplementations§
Source§impl Range
impl Range
Sourcepub fn new(min: Option<f64>, max: Option<f64>) -> Result<Self>
pub fn new(min: Option<f64>, max: Option<f64>) -> Result<Self>
Create a new range constraint with inclusive bounds.
§Errors
Returns InvalidRange if min or max is NaN (NaN causes non-deterministic serialization).
Sourcepub fn min_exclusive(self) -> Self
pub fn min_exclusive(self) -> Self
Set whether the minimum bound is inclusive.
Sourcepub fn max_exclusive(self) -> Self
pub fn max_exclusive(self) -> Self
Set whether the maximum bound is inclusive.
Sourcepub fn matches(&self, value: &ConstraintValue) -> Result<bool>
pub fn matches(&self, value: &ConstraintValue) -> Result<bool>
Check if a value is within the range.
Returns Ok(false) for non-numeric values or NaN.
Sourcepub fn validate_attenuation(&self, child: &Range) -> Result<()>
pub fn validate_attenuation(&self, child: &Range) -> Result<()>
Validate that child is a valid attenuation (subset of parent range).
Checks both numeric bounds AND inclusivity flags:
- Child min must be >= parent min
- Child max must be <= parent max
- If parent bound is exclusive, child cannot make it inclusive (would widen)
Sourcepub fn contains_value(&self, value: f64) -> bool
pub fn contains_value(&self, value: f64) -> bool
Check if an exact value is within the range.
Used for Range -> Exact attenuation validation.