Struct fog_pack::validator::BinValidator[][src]

pub struct BinValidator {
    pub comment: String,
    pub bits_clr: ByteBuf,
    pub bits_set: ByteBuf,
    pub max: ByteBuf,
    pub min: ByteBuf,
    pub ex_max: bool,
    pub ex_min: bool,
    pub max_len: u32,
    pub min_len: u32,
    pub in_list: Vec<ByteBuf>,
    pub nin_list: Vec<ByteBuf>,
    pub query: bool,
    pub bit: bool,
    pub ord: bool,
    pub size: bool,
}

Validator for byte sequences.

This validator type will only pass binary values (a sequence of bytes). A binary sequence can also be treated as a little-endian arbitrary-length unsigned integer. Validation passes if:

  • The bits set in bits_clr are cleared in the byte sequence.
  • The bits set in bits_set are set in the byte sequence.
  • If max has 1 or more bytes, the value is less than the maximum in max, or equal to it if ex_max is not set to true.
  • The value is greater than the minimum in min, or equal to it if ex_min is not set to true.
  • The value’s length in bytes is less than or equal to the value in max_len.
  • The value’s length in bytes is greater than or equal to the value in min_len.
  • If the in list is not empty, the value must be among the values in the list.
  • The value must not be among the values 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: empty
  • bits_set: empty
  • max: empty
  • min: empty
  • ex_max: false
  • ex_min: false
  • max_len: u32::MAX
  • min_len: 0
  • in_list: empty
  • nin_list: empty
  • query: false
  • bit: false
  • ord: false
  • size: false

Fields

comment: String

An optional comment explaining the validator.

bits_clr: ByteBuf

A byte sequence used as a bit field. Any bits set in it must be cleared in an allowed value.

bits_set: ByteBuf

A byte sequence used as a bit field. Any bits set in it must be set in an allowed value.

max: ByteBuf

The maximum allowed value, as a little-endian arbitrary-length unsigned integer. If no bytes are present, there is no maximum.

min: ByteBuf

The minimum allowed value, as a little-endian arbitrary-length unsigned integer.

ex_max: bool

Changes max into an exclusive maximum.

ex_min: bool

Changes min into an exclusive maximum.

max_len: u32

Set the maximum allowed number of bytes.

min_len: u32

Set the minimum allowed number of bytes.

in_list: Vec<ByteBuf>

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

nin_list: Vec<ByteBuf>

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.

size: bool

If true, queries against matching spots may set the min_len and max_len values to non-defaults.

Implementations

impl BinValidator[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: impl Into<Vec<u8>>) -> Self[src]

Choose which bits must be set.

pub fn bits_clr(self, bits_clr: impl Into<Vec<u8>>) -> Self[src]

Choose which bits must be cleared.

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

Set the maximum allowed value.

pub fn min(self, min: impl Into<Vec<u8>>) -> 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 max_len(self, max_len: u32) -> Self[src]

Set the maximum number of allowed bytes.

pub fn min_len(self, min_len: u32) -> Self[src]

Set the minimum number of allowed bytes.

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

Add a value to the in list.

pub fn nin_add(self, add: impl Into<Vec<u8>>) -> 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 size(self, size: bool) -> Self[src]

Set whether or not queries can use the max_len and min_len values.

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

Build this into a Validator enum.

Trait Implementations

impl Clone for BinValidator[src]

impl Debug for BinValidator[src]

impl Default for BinValidator[src]

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

impl PartialEq<BinValidator> for BinValidator[src]

impl Serialize for BinValidator[src]

impl StructuralPartialEq for BinValidator[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>,