docx_rust/document/
field_char.rs1use hard_xml::{XmlRead, XmlWrite};
2
3use crate::{__string_enum, __xml_test_suites};
4
5#[derive(Debug, Default, XmlRead, XmlWrite, Clone)]
13#[cfg_attr(test, derive(PartialEq))]
14#[xml(tag = "w:fldChar")]
15pub struct FieldChar {
16 #[xml(attr = "w:fldCharType")]
18 pub ty: Option<CharType>,
19}
20
21impl<T: Into<Option<CharType>>> From<T> for FieldChar {
22 fn from(val: T) -> Self {
23 FieldChar { ty: val.into() }
24 }
25}
26
27#[derive(Debug, Clone)]
31#[cfg_attr(test, derive(PartialEq))]
32pub enum CharType {
33 Begin,
35 Separate,
37 End,
39}
40
41__string_enum! {
42 CharType {
43 Begin = "begin",
44 Separate = "separate",
45 End = "end",
46 }
47}
48
49__xml_test_suites!(
50 FieldChar,
51 FieldChar::from(CharType::Begin),
52 r#"<w:fldChar w:fldCharType="begin"/>"#,
53);