Skip to main content

XmlDocument

Struct XmlDocument 

Source
pub struct XmlDocument { /* private fields */ }
Expand description

Reusable owned XML document.

The parsed view is retained across read-only operations. Every successful mutation increments Self::generation and invalidates all identities captured from previous views.

Implementations§

Source§

impl XmlDocument

Source

pub fn parse( xml: impl AsRef<str> + Into<String>, ) -> Result<Self, XmlDocumentError>

Parse and own an XML document using conservative XML input defaults. Borrowed input is size-checked before it is copied into owned storage.

Source

pub fn parse_with_policy( xml: impl AsRef<str> + Into<String>, policy: &impl XmlDocumentPolicy, ) -> Result<Self, XmlDocumentError>

Parse and own XML under the same immutable policy used by an operation. The policy’s byte ceiling is checked before borrowed input is copied.

Source

pub const fn identity(&self) -> DocumentIdentity

Return this document’s stable provenance identity.

Source

pub const fn generation(&self) -> u64

Return the current mutation generation.

Source

pub fn as_xml(&self) -> &str

Return the deterministic serialized representation of this generation.

Source

pub fn into_xml(self) -> String

Consume the document and return its deterministic serialization.

Source

pub fn with_view<R>( &self, operation: impl for<'a> FnOnce(DocumentView<'a>) -> R, ) -> R

Borrow the retained parsed view without reparsing.

Source

pub fn replace_element( &mut self, target: NodeIdentity, replacement: &str, ) -> Result<(), XmlDocumentError>

Replace one complete element with a well-formed element fragment.

Source

pub fn replace_node_with_fragment( &mut self, target: NodeIdentity, replacement: &str, ) -> Result<(), XmlDocumentError>

Replace one complete node with an XML fragment valid in its parent context.

This operation is intended for XMLEnc Content replacement, where one EncryptedData element can expand into multiple sibling nodes.

Source

pub fn replace_content( &mut self, target: NodeIdentity, replacement: &str, ) -> Result<(), XmlDocumentError>

Replace all children of one element with a well-formed XML fragment.

Source

pub fn replace_contents( &mut self, replacements: &[(NodeIdentity, String)], ) -> Result<(), XmlDocumentError>

Replace the children of several non-overlapping elements atomically.

All identities must belong to the current generation. Every boundary is checked in one validation candidate, then the final candidate is parsed and either commits as one new generation or leaves the document unchanged.

Source

pub fn append_child( &mut self, target: NodeIdentity, child: &str, ) -> Result<(), XmlDocumentError>

Append a well-formed XML fragment as the last child of an element.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.