pub struct Comment {
pub content: String,
pub position: CommentPosition,
pub xpath: Option<String>,
pub line_number: Option<usize>,
pub column_number: Option<usize>,
pub preserve_formatting: bool,
pub processing_hints: IndexMap<String, String>,
}
Expand description
Enhanced comment structure with position and location metadata
Fields§
§content: String
The comment content (without markers)
position: CommentPosition
Position relative to the parent element
xpath: Option<String>
XPath-like location reference for precise positioning
line_number: Option<usize>
Line number in original XML (for debugging/tooling)
column_number: Option<usize>
Column number in original XML (for debugging/tooling)
preserve_formatting: bool
Whether this comment should be preserved during canonicalization
processing_hints: IndexMap<String, String>
Processing hints for specific output formats
Implementations§
Source§impl Comment
impl Comment
Sourcepub fn new(content: String, position: CommentPosition) -> Self
pub fn new(content: String, position: CommentPosition) -> Self
Create a new comment with minimal information
Sourcepub fn with_location(
content: String,
position: CommentPosition,
xpath: Option<String>,
line_number: Option<usize>,
column_number: Option<usize>,
) -> Self
pub fn with_location( content: String, position: CommentPosition, xpath: Option<String>, line_number: Option<usize>, column_number: Option<usize>, ) -> Self
Create a comment with location metadata
Sourcepub fn document_comment(content: String) -> Self
pub fn document_comment(content: String) -> Self
Create a comment for document-level usage
Sourcepub fn preserve_formatting(self) -> Self
pub fn preserve_formatting(self) -> Self
Set preservation of original formatting
Sourcepub fn canonical_content(&self) -> String
pub fn canonical_content(&self) -> String
Get canonical comment content with proper whitespace normalization
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Comment
impl<'de> Deserialize<'de> for Comment
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
impl StructuralPartialEq for Comment
Auto Trait Implementations§
impl Freeze for Comment
impl RefUnwindSafe for Comment
impl Send for Comment
impl Sync for Comment
impl Unpin for Comment
impl UnwindSafe for Comment
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