Skip to main content

BytesValidator

Struct BytesValidator 

Source
pub struct BytesValidator<'a> {
Show 14 fields pub len: Option<u64>, pub min_len: Option<u64>, pub max_len: Option<u64>, pub pattern: Option<Regex>, pub prefix: Option<&'a [u8]>, pub suffix: Option<&'a [u8]>, pub contains: Option<&'a [u8]>, pub in_: Option<Box<[&'a [u8]]>>, pub not_in: Option<Box<[&'a [u8]]>>, pub well_known: Option<WellKnown>, pub const_: Option<&'a [u8]>, pub cel: Option<Box<[CelRule]>>, pub required: Option<bool>, pub ignore: Option<Ignore>,
}
Expand description

Used by the bytes macro to define validation rules.

Fieldsยง

ยงlen: Option<u64>

Specifies the exact length for this bytes field to be considered valid.

ยงmin_len: Option<u64>

The minimum length for this field in order to be considered valid.

ยงmax_len: Option<u64>

The maximum length for this field in order to be considered valid.

ยงpattern: Option<Regex>

The pattern that this field must match in order to be valid.

ยงprefix: Option<&'a [u8]>

A prefix that this field must contain in order to be valid.

ยงsuffix: Option<&'a [u8]>

A suffix that this field must contain in order to be valid.

ยงcontains: Option<&'a [u8]>

A subset of bytes that this field must contain in order to be valid.

ยงin_: Option<Box<[&'a [u8]]>>

Only the values in this list will be considered valid for this field.

ยงnot_in: Option<Box<[&'a [u8]]>>

The values in this list will be considered invalid for this field.

ยงwell_known: Option<WellKnown>ยงconst_: Option<&'a [u8]>

Only this specific value will be considered valid for this field.

ยงcel: Option<Box<[CelRule]>>

Adds custom validation using one or more CelRules to this field.

ยงrequired: Option<bool>

Marks the field as invalid if unset.

ยงignore: Option<Ignore>

Implementationsยง

Sourceยง

impl<'a> BytesValidator<'a>

Source

pub fn builder() -> BytesValidatorBuilder<'a>

Create an instance of BytesValidator using the builder syntax

Trait Implementationsยง

Sourceยง

impl<'a> Clone for BytesValidator<'a>

Sourceยง

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

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

Performs copy-assignment from source. Read more
Sourceยง

impl<'a> Debug for BytesValidator<'a>

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl<'a> From<BytesValidator<'a>> for ProtoOption

Sourceยง

fn from(validator: BytesValidator<'a>) -> Self

Converts to this type from the input type.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.