lex_babel/formats/rfc_xml/
mod.rs1use crate::error::FormatError;
19use crate::format::{Format, SerializedDocument};
20use lex_core::lex::ast::Document;
21use std::collections::HashMap;
22
23mod parser;
24
25pub struct RfcXmlFormat;
26
27impl Format for RfcXmlFormat {
28 fn name(&self) -> &str {
29 "rfc_xml"
30 }
31
32 fn description(&self) -> &str {
33 "IETF RFC XML Format (v3)"
34 }
35
36 fn file_extensions(&self) -> &[&str] {
37 &["rfcxml"]
38 }
39
40 fn supports_parsing(&self) -> bool {
41 true
42 }
43
44 fn supports_serialization(&self) -> bool {
45 false
46 }
47
48 fn parse(&self, source: &str) -> Result<Document, FormatError> {
49 let ir_doc = parser::parse_to_ir(source)?;
51
52 Ok(crate::from_ir(&ir_doc))
54 }
55
56 fn serialize(&self, _doc: &Document) -> Result<String, FormatError> {
57 Err(FormatError::NotSupported(
58 "RFC XML serialization not implemented".to_string(),
59 ))
60 }
61
62 fn serialize_with_options(
63 &self,
64 _doc: &Document,
65 _options: &HashMap<String, String>,
66 ) -> Result<SerializedDocument, FormatError> {
67 Err(FormatError::NotSupported(
68 "RFC XML serialization not implemented".to_string(),
69 ))
70 }
71}