Struct fog_pack::validator::IntValidator[][src]

pub struct IntValidator {
    pub comment: String,
    pub bits_clr: u64,
    pub bits_set: u64,
    pub max: Integer,
    pub min: Integer,
    pub ex_max: bool,
    pub ex_min: bool,
    pub in_list: Vec<Integer>,
    pub nin_list: Vec<Integer>,
    pub query: bool,
    pub bit: bool,
    pub ord: bool,
}

Validator for integer values.

This validator type will only pass integers. Validation passes if:

  • The bits set in bits_clr are cleared in the integer
  • The bits set in bits_set are set in the integer
  • The integer is less than the maximum in max, or equal to it if ex_max is not set to true.
  • The integer 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 integer must be among the integers in it.
  • The integer must not be among the integers in the nin list.

Defaults

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

  • comment: “”
  • bits_clr: 0
  • bits_set: 0
  • max: u64::MAX
  • min: i64::MIN
  • ex_max: false
  • ex_min: false
  • in_list: empty
  • nin_list: empty
  • query: false
  • bit: false
  • ord: false

Fields

comment: String

An optional comment explaining the validator.

bits_clr: u64

An unsigned 64-bit integers used as a bit field. Any bits set in it must be cleared in an allowed value.

bits_set: u64

An unsigned 64-bit integers used as a bit field. Any bits set in it must be set in an allowed value.

max: Integer

The maximum allowed integer value.

min: Integer

The minimum allowed integer value.

ex_max: bool

Changes max into an exclusive maximum.

ex_min: bool

Changes min into an exclusive maximum.

in_list: Vec<Integer>

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

nin_list: Vec<Integer>

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.

bit: bool

If true, queries against matching spots may set the bits_clr and bits_set values to be non-zero.

ord: bool

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

Implementations

impl IntValidator[src]

pub fn new() -> Self[src]

Make a new validator with the default configuration.

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

Set a comment for the validator.

pub fn bits_set(self, bits_set: u64) -> Self[src]

Choose which bits must be set.

pub fn bits_clr(self, bits_clr: u64) -> Self[src]

Choose which bits must be cleared.

pub fn max(self, max: impl Into<Integer>) -> Self[src]

Set the maximum allowed value.

pub fn min(self, min: impl Into<Integer>) -> Self[src]

Set the minimum allowed value.

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

Set whether or or not max is an exclusive maximum.

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

Set whether or or not min is an exclusive maximum.

pub fn in_add(self, add: impl Into<Integer>) -> Self[src]

Add a value to the in list.

pub fn nin_add(self, add: impl Into<Integer>) -> Self[src]

Add a value to the nin list.

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

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

pub fn bit(self, bit: bool) -> Self[src]

Set whether or not queries can use the bits_clr and bits_set values.

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

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

pub fn build(self) -> Validator[src]

Build this into a Validator enum.

Trait Implementations

impl Clone for IntValidator[src]

impl Debug for IntValidator[src]

impl Default for IntValidator[src]

impl<'de> Deserialize<'de> for IntValidator where
    IntValidator: Default
[src]

impl PartialEq<IntValidator> for IntValidator[src]

impl Serialize for IntValidator[src]

impl StructuralPartialEq for IntValidator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,