diff --git a/src/attention.rs b/src/attention.rs index 2438dc6b..f64dbf5b 100644 --- a/src/attention.rs +++ b/src/attention.rs @@ -5,9 +5,7 @@ use error::Error; use ns; #[derive(Debug, Clone)] -pub enum Attention { - Attention, -} +pub struct Attention; pub fn parse_attention(root: &Element) -> Result { if !root.is("attention", ns::ATTENTION) { @@ -16,7 +14,13 @@ pub fn parse_attention(root: &Element) -> Result { for _ in root.children() { return Err(Error::ParseError("Unknown child in attention element.")); } - Ok(Attention::Attention) + Ok(Attention) +} + +pub fn serialise(_: &Attention) -> Element { + Element::builder("attention") + .ns(ns::ATTENTION) + .build() } #[cfg(test)] @@ -41,4 +45,12 @@ mod tests { }; assert_eq!(message, "Unknown child in attention element."); } + + #[test] + fn test_serialise() { + let elem: Element = "".parse().unwrap(); + let attention = attention::Attention; + let elem2 = attention::serialise(&attention); + assert_eq!(elem, elem2); + } }