pub struct NodeDefinition {
pub name: String,
pub spec: NodeSpec,
pub desc: String,
pub groups: Vec<String>,
pub attrs: HashMap<String, Attribute>,
pub default_attrs: HashMap<String, Value>,
pub content_match: Option<ContentMatch>,
pub mark_set: Option<Vec<MarkDefinition>>,
}Expand description
用于描述节点类型的行为规则和属性约束,通过Schema进行统一管理
Fields§
§name: String节点类型的唯一标识符(例如:“dw”, “dxgc”)
spec: NodeSpec节点类型的详细配置规范
desc: String节点类型的描述信息
groups: Vec<String>节点所属的逻辑分组
attrs: HashMap<String, Attribute>节点支持的属性集合(属性名 -> 属性定义)
default_attrs: HashMap<String, Value>节点属性的默认值集合
content_match: Option<ContentMatch>内容匹配规则,定义允许的子节点结构
mark_set: Option<Vec<MarkDefinition>>允许附加的Mark类型集合
Implementations§
Source§impl NodeDefinition
impl NodeDefinition
Sourcepub fn check_content(&self, content: &[Node], schema: &Schema) -> bool
pub fn check_content(&self, content: &[Node], schema: &Schema) -> bool
Sourcepub fn check_attrs(&self, values: &Attrs)
pub fn check_attrs(&self, values: &Attrs)
Sourcepub fn has_required_attrs(&self) -> bool
pub fn has_required_attrs(&self) -> bool
检查节点是否包含必须的属性
Trait Implementations§
Source§impl Clone for NodeDefinition
impl Clone for NodeDefinition
Source§fn clone(&self) -> NodeDefinition
fn clone(&self) -> NodeDefinition
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 NodeDefinition
impl Debug for NodeDefinition
Source§impl PartialEq for NodeDefinition
impl PartialEq for NodeDefinition
impl Eq for NodeDefinition
impl StructuralPartialEq for NodeDefinition
Auto Trait Implementations§
impl Freeze for NodeDefinition
impl RefUnwindSafe for NodeDefinition
impl Send for NodeDefinition
impl Sync for NodeDefinition
impl Unpin for NodeDefinition
impl UnwindSafe for NodeDefinition
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more