F64Validator

Struct F64Validator 

Source
pub struct F64Validator {
    pub comment: String,
    pub max: f64,
    pub min: f64,
    pub ex_max: bool,
    pub ex_min: bool,
    pub in_list: Vec<f64>,
    pub nin_list: Vec<f64>,
    pub query: bool,
    pub ord: bool,
}
Expand description

Validator for 64-bit floating-point values.

This validator will only pass f64 values. Validation passes if:

  • If max is a number, that the value is less than the maximum in max, or equal to it if ex_max is not set to true.
  • If min is a number, that the value is greater than the minimum in min, or equal to it if ex_min is not set to true.
  • If the in list is not empty, the value must be among the values in it. This performs an exact bit-wise match.
  • The value must not be among the values in the nin list. This performas an exact bit-wise match.

§Defaults

Fields that aren’t specified for the validator use their defaults instead. The defaults for each field are:

  • comment: “”
  • max: NaN
  • min: NaN
  • ex_max: false
  • ex_min: false
  • in_list: empty
  • nin_list: empty
  • query: false
  • ord: false

Fields§

§comment: String

An optional comment explaining the validator.

§max: f64

The maximum allowed f64 value. If NaN, it is ignored.

§min: f64

The minimum allowed f64 value. If NaN, it is ignored.

§ex_max: bool

Changes max into an exclusive maximum.

§ex_min: bool

Changes min into an exclusive maximum.

§in_list: Vec<f64>

A vector of specific allowed values, stored under the in field. If empty, this vector is not checked against.

§nin_list: Vec<f64>

A vector of specific unallowed values, stored under the nin field.

§query: bool

If true, queries against matching spots may have values in the in or nin lists.

§ord: bool

If true, queries against matching spots may set the max, min, ex_max, and ex_min values to non-defaults.

Implementations§

Source§

impl F64Validator

Source

pub fn new() -> Self

Make a new validator with the default configuration.

Source

pub fn comment(self, comment: impl Into<String>) -> Self

Set a comment for the validator.

Source

pub fn max(self, max: f64) -> Self

Set the maximum allowed value.

Source

pub fn min(self, min: f64) -> Self

Set the minimum allowed value.

Source

pub fn ex_max(self, ex_max: bool) -> Self

Set whether or or not max is an exclusive maximum.

Source

pub fn ex_min(self, ex_min: bool) -> Self

Set whether or or not min is an exclusive maximum.

Source

pub fn in_add(self, add: f64) -> Self

Add a value to the in list.

Source

pub fn nin_add(self, add: f64) -> Self

Add a value to the nin list.

Source

pub fn query(self, query: bool) -> Self

Set whether or not queries can use the in and nin lists.

Source

pub fn ord(self, ord: bool) -> Self

Set whether or not queries can use the max, min, ex_max, and ex_min values.

Source

pub fn build(self) -> Validator

Build this into a Validator enum.

Trait Implementations§

Source§

impl Clone for F64Validator

Source§

fn clone(&self) -> F64Validator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for F64Validator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for F64Validator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for F64Validator

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for F64Validator

Source§

fn eq(&self, other: &F64Validator) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for F64Validator

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for F64Validator

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,