Skip to main content

MapValidatorBuilder

Struct MapValidatorBuilder 

Source
pub struct MapValidatorBuilder<S: State = Empty> { /* private fields */ }
Expand description

Use builder syntax to set the inputs and finish with build().

Implementations§

Source§

impl<S: State> MapValidatorBuilder<S>

Source

pub fn build(self) -> MapValidator
where S: IsComplete,

Finish building and return the requested object

Source

pub fn keys( self, value: impl Into<ProtoOption>, ) -> MapValidatorBuilder<SetKeys<S>>
where S::Keys: IsUnset,

Optional (Some / Option setters).

The options that will apply to this map’s keys. This is mostly useful when calling the map definition macros, which will automatically convert validators into the option to use here.

Source

pub fn maybe_keys( self, value: Option<impl Into<ProtoOption>>, ) -> MapValidatorBuilder<SetKeys<S>>
where S::Keys: IsUnset,

Optional (Some / Option setters).

The options that will apply to this map’s keys. This is mostly useful when calling the map definition macros, which will automatically convert validators into the option to use here.

Source

pub fn values( self, value: impl Into<ProtoOption>, ) -> MapValidatorBuilder<SetValues<S>>
where S::Values: IsUnset,

Optional (Some / Option setters).

The options that will apply to this map’s values. This is mostly useful when calling the map definition macros, which will automatically convert validators into the option to use here.

Source

pub fn maybe_values( self, value: Option<impl Into<ProtoOption>>, ) -> MapValidatorBuilder<SetValues<S>>
where S::Values: IsUnset,

Optional (Some / Option setters).

The options that will apply to this map’s values. This is mostly useful when calling the map definition macros, which will automatically convert validators into the option to use here.

Source

pub fn min_pairs(self, value: u64) -> MapValidatorBuilder<SetMinPairs<S>>
where S::MinPairs: IsUnset,

Optional (Some / Option setters).

The minimum amount of key-value pairs that this field should have in order to be valid.

Source

pub fn maybe_min_pairs( self, value: Option<u64>, ) -> MapValidatorBuilder<SetMinPairs<S>>
where S::MinPairs: IsUnset,

Optional (Some / Option setters).

The minimum amount of key-value pairs that this field should have in order to be valid.

Source

pub fn max_pairs(self, value: u64) -> MapValidatorBuilder<SetMaxPairs<S>>
where S::MaxPairs: IsUnset,

Optional (Some / Option setters).

The maximum amount of key-value pairs that this field should have in order to be valid.

Source

pub fn maybe_max_pairs( self, value: Option<u64>, ) -> MapValidatorBuilder<SetMaxPairs<S>>
where S::MaxPairs: IsUnset,

Optional (Some / Option setters).

The maximum amount of key-value pairs that this field should have in order to be valid.

Source

pub fn cel(self, value: Box<[CelRule]>) -> MapValidatorBuilder<SetCel<S>>
where S::Cel: IsUnset,

Optional (Some / Option setters).

Adds custom validation using one or more CelRules to this field. These will apply to the map field as a whole. To apply cel rules to the individual keys or values, use the validators for those instead.

Source

pub fn maybe_cel( self, value: Option<Box<[CelRule]>>, ) -> MapValidatorBuilder<SetCel<S>>
where S::Cel: IsUnset,

Optional (Some / Option setters).

Adds custom validation using one or more CelRules to this field. These will apply to the map field as a whole. To apply cel rules to the individual keys or values, use the validators for those instead.

Source

pub fn required(self) -> MapValidatorBuilder<SetRequired<S>>
where S::Required: IsUnset,

Optional (Some / Option setters).

Marks the field as required. This is essentially the same as setting min_pairs to 1.

Source

pub fn maybe_required( self, value: Option<()>, ) -> MapValidatorBuilder<SetRequired<S>>
where S::Required: IsUnset,

Optional (Some / Option setters).

Marks the field as required. This is essentially the same as setting min_pairs to 1.

Source§

impl<S: State> MapValidatorBuilder<S>
where S::Ignore: IsUnset,

Source

pub fn ignore_if_zero_value(self) -> MapValidatorBuilder<SetIgnore<S>>

Rules defined for this field will be ignored if the field is set to its protobuf zero value. No-op for fields that track presence such as optional fields, or messages in proto3.

Source

pub fn ignore_always(self) -> MapValidatorBuilder<SetIgnore<S>>

Rules set for this field will always be ignored.

Trait Implementations§

Source§

impl<S: State> From<MapValidatorBuilder<S>> for ProtoOption

Source§

fn from(value: MapValidatorBuilder<S>) -> 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> 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, 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.