Trait vector_config::ConfigurableNumber
source · pub trait ConfigurableNumber {
type Numeric: Bounded + ToPrimitive + Zero + One;
// Required method
fn class() -> NumberClass;
// Provided methods
fn is_nonzero() -> bool { ... }
fn requires_nonzero_exclusion() -> bool { ... }
fn get_encoded_zero_value() -> Number { ... }
fn get_enforced_min_bound() -> f64 { ... }
fn get_enforced_max_bound() -> f64 { ... }
}
Expand description
A numeric type that can be represented correctly in a JSON Schema document.
Required Associated Types§
sourcetype Numeric: Bounded + ToPrimitive + Zero + One
type Numeric: Bounded + ToPrimitive + Zero + One
The integral numeric type.
We parameterize the “integral” numeric type in this way to allow generating the schema for wrapper types such as
NonZeroU64
, where the overall type must be represented as NonZeroU64
but the integral numeric type that
we’re constraining against is u64
.
Required Methods§
Provided Methods§
sourcefn is_nonzero() -> bool
fn is_nonzero() -> bool
Whether or not this numeric type disallows nonzero values.
sourcefn requires_nonzero_exclusion() -> bool
fn requires_nonzero_exclusion() -> bool
Whether or not a generated schema for this numeric type must explicitly disallow zero values.
In some cases, such as NonZero*
types from std::num
, a numeric type may not support zero values for reasons
of correctness and/or optimization. In some cases, we can simply adjust the normal minimum/maximum bounds in the
schema to encode this. In other cases, such as signed versions like NonZeroI64
, zero is a discrete value
within the minimum and maximum bounds and must be excluded explicitly.
sourcefn get_encoded_zero_value() -> Number
fn get_encoded_zero_value() -> Number
Gets the JSON encoded version of the zero value for the integral numeric type.
sourcefn get_enforced_min_bound() -> f64
fn get_enforced_min_bound() -> f64
Gets the minimum bound for this numeric type, limited by the representable range in JSON Schema.
sourcefn get_enforced_max_bound() -> f64
fn get_enforced_max_bound() -> f64
Gets the maximum bound for this numeric type, limited by the representable range in JSON Schema.