pub trait Input {
type Child<'a>: Input
where Self: 'a;
// Required methods
fn kind(&self) -> Kind;
fn as_bool(&self) -> Option<bool>;
fn as_int(&self) -> Option<Int>;
fn as_f64(&self) -> Option<f64>;
fn as_str(&self) -> Option<Cow<'_, str>>;
fn len(&self) -> usize;
fn item(&self, index: usize) -> Option<Self::Child<'_>>;
fn slot(&self, key: &str) -> Slot<Self::Child<'_>>;
fn each_key(&self, f: &mut dyn FnMut(&str));
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A payload the validator can read in place.
Accessors return None when the value is not of that kind, so a caller
never has to check twice. They are infallible on purpose: a binding that
cannot read its own object has a bug, not a validation failure.
Required Associated Types§
Sourcetype Child<'a>: Input
where
Self: 'a
type Child<'a>: Input where Self: 'a
An element of an array, or the value at a key. Implementations should make this converge, usually to themselves or to a reference to themselves. A type whose child is a strictly new type on every level would make the validator recurse forever at compile time.
Required Methods§
fn kind(&self) -> Kind
fn as_bool(&self) -> Option<bool>
fn as_int(&self) -> Option<Int>
fn as_f64(&self) -> Option<f64>
fn as_str(&self) -> Option<Cow<'_, str>>
fn item(&self, index: usize) -> Option<Self::Child<'_>>
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".