pub trait XmlElement {
// Required methods
fn element_name(&self) -> &'static str;
fn attributes(&self) -> Vec<(String, String)>;
fn from_xml(node: &XmlNode) -> Result<Self, XmlElementError>
where Self: Sized;
// Provided methods
fn child_nodes(&self) -> Vec<XmlNode> { ... }
fn text_content(&self) -> Option<&str> { ... }
fn to_xml(&self) -> String { ... }
fn write_xml(&self, out: &mut String) { ... }
}Expand description
Required Methods§
Sourcefn element_name(&self) -> &'static str
fn element_name(&self) -> &'static str
元素名(如 “TextObject”、“ofd:Page”)。
Sourcefn attributes(&self) -> Vec<(String, String)>
fn attributes(&self) -> Vec<(String, String)>
XML 属性列表。
Provided Methods§
Sourcefn child_nodes(&self) -> Vec<XmlNode>
fn child_nodes(&self) -> Vec<XmlNode>
子元素(作为 XmlNode 提供,便于嵌套序列化)。
Sourcefn text_content(&self) -> Option<&str>
fn text_content(&self) -> Option<&str>
文本内容(简单文本元素)。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".