use crate::line_spacing_type::LineSpacingType; use crate::ReaderError; use std::str::FromStr; use xml::attribute::OwnedAttribute; pub type LineSpacingResult = Result< ( Option, Option, Option, Option, ), ReaderError, >; pub fn read_line_spacing(attributes: &[OwnedAttribute]) -> LineSpacingResult { let mut before: Option = None; let mut after: Option = None; let mut line: Option = None; let mut spacing_type: Option = None; for a in attributes { let local_name = &a.name.local_name; if local_name == "before" { before = Some(u32::from_str(&a.value)?); } else if local_name == "after" { after = Some(u32::from_str(&a.value)?); } else if local_name == "line" { line = Some(u32::from_str(&a.value)?); } else if local_name == "lineRule" { spacing_type = Some(LineSpacingType::from_str(&a.value)?); } } Ok((before, after, line, spacing_type)) }