openehr-its 0.0.128

openEHR ITS (Implementation Technology Specifications): canonical JSON + canonical XML serialization of the RM, the generated ITS-REST 1.1.0 API contract, and the OPT 1.4 and AOM2 archetype XML codecs
Documentation
// @generated by openehr-codegen (emit-opt) — DO NOT EDIT.
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-FileCopyrightText: openEHR Foundation
// SPDX-License-Identifier: Apache-2.0
//! openEHR OPT 1.4 operational-template model + canonical-XML codec.
//!
//! Parse an operational template with [`from_xml`]; the root element is `<template>` (`OPERATIONAL_TEMPLATE`).

mod impls;
pub mod types;

/// Parse an operational template XML document into an [`types::OperationalTemplate`].
///
/// # Errors
/// Propagates canonical-XML parse errors, and refuses a root element other
/// than `<template>`.
pub fn from_xml(xml: &str) -> Result<types::OperationalTemplate, crate::xml::runtime::XmlError> {
    crate::xml::runtime::from_xml_rooted(xml, "template")
}

/// Serialize an [`types::OperationalTemplate`] back to OPT 1.4 XML (root `<template>`,
/// `http://schemas.openehr.org/v1`).
///
/// # Errors
/// Propagates canonical-XML serialization errors.
pub fn to_xml(value: &types::OperationalTemplate) -> Result<String, crate::xml::runtime::XmlError> {
    crate::xml::runtime::to_xml(value, "template", crate::xml::runtime::Namespace::V1)
}