Function patch_xml::patch_xml[][src]

pub fn patch_xml(xmltree: String, patch: String) -> Result<String, String>

Patches an XML file with a generic patch in YAML format

The first parameter is the string that provides the concrete XML structure of a loaded SVD file.
The second parameter is the string that provides a patch in YAML-format.

This method applies the patch on the passed XML structure and tries to load that result into the SVD data structure. Finally, this SVD data structure is returned.

Panics

Currently, the method patch_xml may panic in individual cases when the loading, patching or conversion into the SVD structure fails. This will change in future so that the method will never panic.

Example

use indoc::indoc;
let original_xml = r#"<element>Foo</element>"#;
let patch = indoc!(
    r#"
    element:
        Bar"#
    );
let result_xml = r#"<?xml version="1.0" encoding="UTF-8"?><element>Bar</element>"#;
// Load XML string, patch it and return the result as string
let result = patch_xml::patch_xml(original_xml.to_string(), patch.to_string()).unwrap();
assert_eq!(result, result_xml);