Skip to main content

DynamicMap

Struct DynamicMap 

Source
pub struct DynamicMap { /* private fields */ }
Expand description

(dynamic_map feature) Accepts a map with arbitrary keys and uniform values.

Optional entry-count bounds and an optional validator applied to every value. Coercion: an empty list becomes an empty map (the list counterpart of an empty collection). A non-empty list or any other type is rejected.

Implementations§

Source§

impl DynamicMap

Source

pub fn with_meta(self, meta: Meta) -> Self

Attach human-facing metadata (name, description, examples, default, output conversion).

Source

pub fn new() -> Self

Source

pub fn min_len(self, min: usize) -> Self

Source

pub fn max_len(self, max: usize) -> Self

Source

pub fn values(self, validator: impl Into<Box<dyn Validator>>) -> Self

Validate every value with validator.

Source§

impl DynamicMap

Source

pub fn name(&self) -> &str

The human-readable name.

Source

pub fn description(&self) -> Option<&str>

The description, if any.

Source

pub fn examples(&self) -> &[(Value, Option<String>)]

The example values (each with an optional note).

Source

pub fn default_value(&self) -> Option<&Value>

The default value, if any.

Source

pub fn convert(&self) -> Option<ValueType>

The output conversion target, if any.

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Set the human-readable name (surfaced in error messages).

Source

pub fn with_description(self, text: impl Into<String>) -> Self

Attach a human-readable description.

Source

pub fn with_example(self, value: impl Into<Value>) -> Self

Add an example value.

Source

pub fn with_example_noted( self, value: impl Into<Value>, note: impl Into<String>, ) -> Self

Add an example value with an explanatory note.

Source

pub fn with_default(self, value: impl Into<Value>) -> Self

Set the default value used as an on-error fallback (see the pipeline’s validate stage).

Source

pub fn to_string(self) -> Self

After validation succeeds, cast the value to a string.

Source

pub fn to_int(self) -> Self

After validation succeeds, cast the value to an integer.

Source

pub fn to_float(self) -> Self

After validation succeeds, cast the value to a float.

Source

pub fn to_bool(self) -> Self

After validation succeeds, cast the value to a boolean.

Trait Implementations§

Source§

impl Default for DynamicMap

Source§

fn default() -> DynamicMap

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

impl Validator for DynamicMap

Source§

fn meta(&self) -> &Meta

This validator’s human-facing metadata.
Source§

fn meta_mut(&mut self) -> &mut Meta

Mutable access to this validator’s metadata (backs the builder setters).
Source§

fn check(&self, value: &mut Value) -> Result<(), Error>

The validation rule: check (and coerce) value in place.
Source§

fn validate(&self, value: &mut Value) -> Result<(), Error>

Run check; on error attach this validator’s Meta (innermost wins); on success apply the output conversion in meta().convert, if any.

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