DataLockboxValidator

Struct DataLockboxValidator 

Source
pub struct DataLockboxValidator {
    pub comment: String,
    pub max_len: u32,
    pub min_len: u32,
    pub size: bool,
}
Expand description

Validator for a DataLockbox.

This validator will only pass a DataLockbox value. Validation passes if:

  • The number of bytes in the lockbox is less than or equal to max_len
  • The number of bytes in the lockbox is greater than or equal to min_len

§Defaults

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

  • comment: “”
  • max_len: u32::MAX
  • min_len: 0
  • size: false

§Query Checking

Queries for lockboxes are only allowed to use non default values for max_len and min_len if size is set in the schema’s validator.

Fields§

§comment: String

An optional comment explaining the validator.

§max_len: u32

Set the maximum allowed number of bytes.

§min_len: u32

Set the minimum allowed number of bytes.

§size: bool

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

Implementations§

Source§

impl DataLockboxValidator

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_len(self, max_len: u32) -> Self

Set the maximum number of allowed bytes.

Source

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

Set the minimum number of allowed bytes.

Source

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

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

Source

pub fn build(self) -> Validator

Build this into a Validator enum.

Trait Implementations§

Source§

impl Clone for DataLockboxValidator

Source§

fn clone(&self) -> DataLockboxValidator

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 DataLockboxValidator

Source§

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

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

impl Default for DataLockboxValidator

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for DataLockboxValidator

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 DataLockboxValidator

Source§

fn eq(&self, other: &DataLockboxValidator) -> 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 DataLockboxValidator

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 DataLockboxValidator

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>,