Skip to main content

docx_rs/reader/
bookmark_end.rs

1use std::io::Read;
2use std::str::FromStr;
3
4use super::*;
5
6impl ElementReader for BookmarkEnd {
7    fn read<R: Read>(
8        _r: &mut EventReader<R>,
9        attrs: &[OwnedAttribute],
10    ) -> Result<Self, ReaderError> {
11        let mut id: Option<usize> = None;
12        for a in attrs {
13            let local_name = &a.name.local_name;
14            if local_name == "id" {
15                id = Some(usize::from_str(&a.value)?);
16            }
17        }
18        if let Some(id) = id {
19            Ok(BookmarkEnd::new(id))
20        } else {
21            Err(ReaderError::XMLReadError)
22        }
23    }
24}