//! A small, strict XML reader for the host's answers: one `` element with nested //! elements and text. No DTD, no entities beyond the five predefined ones and numeric character references, //! no processing instructions except a leading XML declaration, no namespaces. /// Maximum size of any XML body accepted, in bytes. pub const MAX_XML_BYTES: usize = 1024 * 1024; /// Maximum element nesting depth (the root is depth 1). pub const MAX_XML_DEPTH: usize = 8; /// Maximum number of elements in one document. pub const MAX_XML_ELEMENTS: usize = 16 * 1024; /// Maximum length of one element's text, in bytes after unescaping. pub const MAX_XML_TEXT_BYTES: usize = 64 * 1024; /// Maximum number of attributes on one element. pub const MAX_XML_ATTRIBUTES: usize = 8; /// One element: its name, attributes, text (concatenated, unescaped, not trimmed) and child elements. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct Element { /// Tag name, case-sensitive. pub name: String, /// Attributes in document order, values unescaped. pub attributes: Vec<(String, String)>, /// Text content directly inside this element. pub text: String, /// Child elements in document order. pub children: Vec, } /// A parsed host answer. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Document { /// The root element's `status_code` attribute (the host's status; 200 = OK). pub status_code: u32, /// The root element's `status_message` attribute, if any (UNKNOWN U27). pub status_message: Option, /// The root element itself. pub root: Element, } /// Parses an XML answer. The root element must be `root` and carry a decimal `status_code`. /// /// # Errors /// [`crate::Error::TooLarge`] over [`MAX_XML_BYTES`] or any other cap, [`crate::Error::Malformed`] for anything that /// is not well-formed or uses a refused feature. Phase A: always [`crate::Error::Unimplemented`]. pub fn parse(body: &[u8]) -> crate::Result { let _ = body; Err(crate::Error::Unimplemented) }