pub struct ComponentSchema {
pub props: HashMap<String, PropSchema>,
pub self_closing: bool,
pub allowed_children: Option<Vec<String>>,
pub description: Option<String>,
}Expand description
Schema definition for a single component.
Fields§
§props: HashMap<String, PropSchema>Allowed props keyed by attribute name.
self_closing: boolWhether the component must be self-closing (no children).
allowed_children: Option<Vec<String>>Optional list of allowed child component names.
If None, any children are allowed. If Some, only listed component names
(and standard Markdown nodes) are permitted as direct children.
description: Option<String>Human-readable description for tooling and error messages.
Implementations§
Source§impl ComponentSchema
impl ComponentSchema
pub fn new() -> Self
Sourcepub fn prop(self, name: &str, schema: PropSchema) -> Self
pub fn prop(self, name: &str, schema: PropSchema) -> Self
Add a prop definition. Builder pattern.
Sourcepub fn self_closing(self, val: bool) -> Self
pub fn self_closing(self, val: bool) -> Self
Mark as self-closing (must not have children).
Sourcepub fn allowed_children(self, names: Vec<&str>) -> Self
pub fn allowed_children(self, names: Vec<&str>) -> Self
Restrict allowed child component names.
Sourcepub fn description(self, desc: &str) -> Self
pub fn description(self, desc: &str) -> Self
Set a description.
Trait Implementations§
Source§impl Clone for ComponentSchema
impl Clone for ComponentSchema
Source§fn clone(&self) -> ComponentSchema
fn clone(&self) -> ComponentSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ComponentSchema
impl Debug for ComponentSchema
Source§impl Default for ComponentSchema
impl Default for ComponentSchema
Source§fn default() -> ComponentSchema
fn default() -> ComponentSchema
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ComponentSchema
impl<'de> Deserialize<'de> for ComponentSchema
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 ComponentSchema
impl RefUnwindSafe for ComponentSchema
impl Send for ComponentSchema
impl Sync for ComponentSchema
impl Unpin for ComponentSchema
impl UnsafeUnpin for ComponentSchema
impl UnwindSafe for ComponentSchema
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