umya_spreadsheet/structs/
font_name.rs1use std::io::Cursor;
3
4use quick_xml::{
5 Reader,
6 Writer,
7 events::BytesStart,
8};
9
10use super::StringValue;
11use crate::{
12 reader::driver::get_attribute,
13 writer::driver::write_start_tag,
14};
15
16#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
17pub struct FontName {
18 pub(crate) val: StringValue,
19}
20
21impl FontName {
22 #[inline]
23 #[must_use]
24 pub fn val(&self) -> &str {
25 self.val.value_str()
26 }
27
28 #[inline]
29 #[must_use]
30 #[deprecated(since = "3.0.0", note = "Use val()")]
31 pub fn get_val(&self) -> &str {
32 self.val()
33 }
34
35 #[inline]
36 pub fn set_val<S: Into<String>>(&mut self, value: S) -> &mut Self {
37 self.val.set_value(value);
38 self
39 }
40
41 #[inline]
42 pub(crate) fn set_attributes<R: std::io::BufRead>(
43 &mut self,
44 _reader: &mut Reader<R>,
45 e: &BytesStart,
46 ) {
47 self.val.set_value_string(get_attribute(e, b"val").unwrap());
48 }
49
50 #[inline]
51 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>, tag_name: &str) {
52 if self.val.has_value() {
54 write_start_tag(
55 writer,
56 tag_name,
57 vec![("val", self.val.value_str()).into()],
58 true,
59 );
60 }
61 }
62}