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§

source

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§

source

fn class() -> NumberClass

Gets the class of this numeric type.

Provided Methods§

source

fn is_nonzero() -> bool

Whether or not this numeric type disallows nonzero values.

source

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.

source

fn get_encoded_zero_value() -> Number

Gets the JSON encoded version of the zero value for the integral numeric type.

source

fn get_enforced_min_bound() -> f64

Gets the minimum bound for this numeric type, limited by the representable range in JSON Schema.

source

fn get_enforced_max_bound() -> f64

Gets the maximum bound for this numeric type, limited by the representable range in JSON Schema.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ConfigurableNumber for f32

§

type Numeric = f32

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for f64

§

type Numeric = f64

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for i8

§

type Numeric = i8

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for i16

§

type Numeric = i16

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for i32

§

type Numeric = i32

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for i64

§

type Numeric = i64

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for isize

§

type Numeric = isize

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for u8

§

type Numeric = u8

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for u16

§

type Numeric = u16

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for u32

§

type Numeric = u32

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for u64

§

type Numeric = u64

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for usize

§

type Numeric = usize

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for NonZeroI8

source§

impl ConfigurableNumber for NonZeroI16

source§

impl ConfigurableNumber for NonZeroI32

source§

impl ConfigurableNumber for NonZeroI64

source§

impl ConfigurableNumber for NonZeroU8

§

type Numeric = u8

source§

fn is_nonzero() -> bool

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for NonZeroU16

§

type Numeric = u16

source§

fn is_nonzero() -> bool

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for NonZeroU32

§

type Numeric = u32

source§

fn is_nonzero() -> bool

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for NonZeroU64

§

type Numeric = u64

source§

fn is_nonzero() -> bool

source§

fn class() -> NumberClass

source§

impl ConfigurableNumber for NonZeroUsize

§

type Numeric = usize

source§

fn is_nonzero() -> bool

source§

fn class() -> NumberClass

Implementors§