docx_rs/reader/
shading.rs1use std::io::Read;
2use std::str::FromStr;
3
4use crate::types::*;
5
6use super::*;
7
8impl ElementReader for Shading {
9 fn read<R: Read>(
10 _r: &mut EventReader<R>,
11 attrs: &[OwnedAttribute],
12 ) -> Result<Self, ReaderError> {
13 let mut shd = Shading::new();
14 for a in attrs {
15 let local_name = &a.name.local_name;
16 if local_name == "val" {
17 if let Ok(val) = ShdType::from_str(&a.value) {
18 shd = shd.shd_type(val);
19 }
20 } else if local_name == "color" {
21 shd = shd.color(&a.value);
22 } else if local_name == "fill" {
23 shd = shd.fill(&a.value);
24 }
25 }
26 Ok(shd)
27 }
28}