Skip to main content

umya_spreadsheet/structs/drawing/
alpha.rs

1// a:alpha
2use std::io::Cursor;
3
4use quick_xml::{
5    Reader,
6    Writer,
7    events::BytesStart,
8};
9
10use crate::{
11    reader::driver::get_attribute,
12    writer::driver::write_start_tag,
13};
14
15#[derive(Clone, Default, Debug)]
16pub struct Alpha {
17    val: Box<str>,
18}
19impl Alpha {
20    #[inline]
21    #[must_use]
22    pub fn val(&self) -> &str {
23        &self.val
24    }
25
26    #[inline]
27    #[must_use]
28    #[deprecated(since = "3.0.0", note = "Use val()")]
29    pub fn get_val(&self) -> &str {
30        self.val()
31    }
32
33    #[inline]
34    pub fn set_val<S: Into<String>>(&mut self, value: S) {
35        self.val = value.into().into_boxed_str();
36    }
37
38    #[inline]
39    pub(crate) fn set_attributes<R: std::io::BufRead>(
40        &mut self,
41        _reader: &mut Reader<R>,
42        e: &BytesStart,
43    ) {
44        self.set_val(get_attribute(e, b"val").unwrap());
45    }
46
47    #[inline]
48    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
49        // a:alpha
50        write_start_tag(writer, "a:alpha", vec![("val", &self.val).into()], true);
51    }
52}