Skip to main content

umya_spreadsheet/structs/drawing/
end_connection.rs

1// a:endCxn
2use std::io::Cursor;
3
4use quick_xml::{
5    Reader,
6    Writer,
7    events::BytesStart,
8};
9
10use super::super::super::UInt32Value;
11use crate::{
12    reader::driver::get_attribute,
13    writer::driver::write_start_tag,
14};
15
16#[derive(Clone, Default, Debug)]
17pub struct EndConnection {
18    id:    UInt32Value,
19    index: UInt32Value,
20}
21impl EndConnection {
22    #[inline]
23    #[must_use]
24    pub fn id(&self) -> u32 {
25        self.id.value()
26    }
27
28    #[inline]
29    #[must_use]
30    #[deprecated(since = "3.0.0", note = "Use id()")]
31    pub fn get_id(&self) -> u32 {
32        self.id()
33    }
34
35    #[inline]
36    pub fn set_id(&mut self, value: u32) {
37        self.id.set_value(value);
38    }
39
40    #[inline]
41    #[must_use]
42    pub fn index(&self) -> u32 {
43        self.index.value()
44    }
45
46    #[inline]
47    #[must_use]
48    #[deprecated(since = "3.0.0", note = "Use index()")]
49    pub fn get_index(&self) -> u32 {
50        self.index()
51    }
52
53    #[inline]
54    pub fn set_index(&mut self, value: u32) {
55        self.index.set_value(value);
56    }
57
58    #[inline]
59    pub(crate) fn set_attributes<R: std::io::BufRead>(
60        &mut self,
61        _reader: &mut Reader<R>,
62        e: &BytesStart,
63    ) {
64        self.id.set_value_string(get_attribute(e, b"id").unwrap());
65        self.index
66            .set_value_string(get_attribute(e, b"idx").unwrap());
67    }
68
69    #[inline]
70    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
71        write_start_tag(
72            writer,
73            "a:endCxn",
74            vec![
75                ("id", self.id.value_string()).into(),
76                ("idx", self.index.value_string()).into(),
77            ],
78            true,
79        );
80    }
81}