pub struct StaticMap { /* private fields */ }Expand description
(static_map feature) Accepts a map with a known set of keys.
Each declared key is either required or optional, and may carry a validator for its
value. By default keys not declared in the schema are rejected; call
StaticMap::allow_unknown to permit them.
Implementations§
Source§impl StaticMap
impl StaticMap
Sourcepub fn with_meta(self, meta: Meta) -> Self
pub fn with_meta(self, meta: Meta) -> Self
Attach human-facing metadata (name, description, examples, default, output conversion).
pub fn new() -> Self
Sourcepub fn required(
self,
key: impl Into<String>,
validator: impl Into<Box<dyn Validator>>,
) -> Self
pub fn required( self, key: impl Into<String>, validator: impl Into<Box<dyn Validator>>, ) -> Self
Declare a required key whose value is validated by validator.
Sourcepub fn optional(
self,
key: impl Into<String>,
validator: impl Into<Box<dyn Validator>>,
) -> Self
pub fn optional( self, key: impl Into<String>, validator: impl Into<Box<dyn Validator>>, ) -> Self
Declare an optional key whose value, when present, is validated by validator.
Sourcepub fn required_any(self, key: impl Into<String>) -> Self
pub fn required_any(self, key: impl Into<String>) -> Self
Declare a required key whose value is accepted without validation.
Sourcepub fn optional_any(self, key: impl Into<String>) -> Self
pub fn optional_any(self, key: impl Into<String>) -> Self
Declare an optional key whose value is accepted without validation.
Sourcepub fn deny_unknown(self) -> Self
pub fn deny_unknown(self) -> Self
Reject keys not declared in the schema (the default).
Sourcepub fn allow_unknown(self) -> Self
pub fn allow_unknown(self) -> Self
Accept keys not declared in the schema, leaving their values untouched.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StaticMap
impl !Send for StaticMap
impl !Sync for StaticMap
impl !UnwindSafe for StaticMap
impl Freeze for StaticMap
impl Unpin for StaticMap
impl UnsafeUnpin for StaticMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> WithMeta for Twhere
T: Validator,
impl<T> WithMeta for Twhere
T: Validator,
Source§fn description(&self) -> Option<&str>
fn description(&self) -> Option<&str>
The description, if any.
Source§fn examples(&self) -> &[(Value, Option<String>)]
fn examples(&self) -> &[(Value, Option<String>)]
The example values (each with an optional note).
Source§fn default_value(&self) -> Option<&Value>
fn default_value(&self) -> Option<&Value>
The default value, if any.
Source§fn with_name(self, name: impl Into<String>) -> Self
fn with_name(self, name: impl Into<String>) -> Self
Set the human-readable name (surfaced in error messages).
Source§fn with_description(self, text: impl Into<String>) -> Self
fn with_description(self, text: impl Into<String>) -> Self
Attach a human-readable description.
Source§fn with_example(self, value: impl Into<Value>) -> Self
fn with_example(self, value: impl Into<Value>) -> Self
Add an example value.
Source§fn with_example_noted(
self,
value: impl Into<Value>,
note: impl Into<String>,
) -> Self
fn with_example_noted( self, value: impl Into<Value>, note: impl Into<String>, ) -> Self
Add an example value with an explanatory note.
Source§fn with_default(self, value: impl Into<Value>) -> Self
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).