pub struct Schema {
pub components: HashMap<String, ComponentSchema>,
pub strict: bool,
}Expand description
A schema registry mapping component names to their definitions.
§Example
use rdx_schema::{Schema, ComponentSchema, PropSchema, PropType};
let schema = Schema::new()
.component("Notice", ComponentSchema::new()
.prop("type", PropSchema::required(PropType::String))
.prop("title", PropSchema::optional(PropType::String))
)
.component("Badge", ComponentSchema::new()
.prop("label", PropSchema::required(PropType::String))
.prop("color", PropSchema::optional(PropType::String))
);Fields§
§components: HashMap<String, ComponentSchema>Component definitions keyed by tag name.
strict: boolWhen true, components not in the schema produce an error. When false (default), unknown components are silently accepted.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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