pub struct Registry { /* private fields */ }Expand description
Maps "type" tags to validator constructors.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn register(
&mut self,
tag: impl Into<String>,
constructor: impl Fn(&Node<'_>) -> Result<Box<dyn Validator>, SchemaError> + 'static,
)
pub fn register( &mut self, tag: impl Into<String>, constructor: impl Fn(&Node<'_>) -> Result<Box<dyn Validator>, SchemaError> + 'static, )
Register (or replace) the constructor for tag.
Sourcepub fn build(
&self,
value: &LocatedValue,
) -> Result<Box<dyn Validator>, SchemaError>
pub fn build( &self, value: &LocatedValue, ) -> Result<Box<dyn Validator>, SchemaError>
Build a validator from a located schema node, seeding source locations into errors.
Sourcepub fn build_value(
&self,
value: &Value,
) -> Result<Box<dyn Validator>, SchemaError>
pub fn build_value( &self, value: &Value, ) -> Result<Box<dyn Validator>, SchemaError>
Build a validator from a bare Value (errors carry no source location).
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
A registry pre-loaded with every built-in validator type.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !Send for Registry
impl !Sync for Registry
impl !UnwindSafe for Registry
impl Freeze for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
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