pub struct Element {
pub name: String,
pub namespace: Option<String>,
pub attributes: IndexMap<String, String>,
pub children: Vec<Node>,
}
Expand description
XML element in the AST
Represents a single XML element with its name, namespace, attributes, and child nodes. The structure maintains deterministic ordering of attributes using IndexMap to ensure consistent XML output.
Fields§
§name: String
Element name (local name without prefix)
namespace: Option<String>
Namespace URI if element is namespaced
attributes: IndexMap<String, String>
Element attributes (name -> value) Uses IndexMap to ensure deterministic attribute ordering
children: Vec<Node>
Child nodes (elements, text, comments)
Implementations§
Source§impl Element
impl Element
Sourcepub fn with_namespace(self, ns: impl Into<String>) -> Self
pub fn with_namespace(self, ns: impl Into<String>) -> Self
Sourcepub fn add_comment(&mut self, comment: Comment)
pub fn add_comment(&mut self, comment: Comment)
Add a structured comment to this element
§Arguments
comment
- The structured comment with position information
§Example
use ddex_builder::ast::Element;
use ddex_core::models::{Comment, CommentPosition};
let mut element = Element::new("Release");
let comment = Comment::new("Release generated by system".to_string(), CommentPosition::Before);
element.add_comment(comment);
Sourcepub fn add_simple_comment(&mut self, comment: impl Into<String>)
pub fn add_simple_comment(&mut self, comment: impl Into<String>)
Sourcepub fn with_comment(self, content: String, position: CommentPosition) -> Self
pub fn with_comment(self, content: String, position: CommentPosition) -> Self
Add a comment with a specific position
§Arguments
content
- The comment contentposition
- The position where the comment should appear
§Example
use ddex_builder::ast::Element;
use ddex_core::models::CommentPosition;
let element = Element::new("Release")
.with_comment("Release comment".to_string(), CommentPosition::Before);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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