easyofd_reader/model/
stamp_annot_vo.rs1#[derive(Debug, Clone)]
14#[deprecated(since = "1.0.0", note = "使用 easyofd_core::StampAnnotEntity 替代")]
15#[allow(deprecated)]
16pub struct StampAnnotVo {
17 pub stamp_annots: Vec<String>,
19 pub img_byte: Vec<u8>,
21 pub image_type: String,
23}
24
25#[allow(deprecated)]
26impl StampAnnotVo {
27 #[must_use]
29 pub fn new() -> Self {
30 Self {
31 stamp_annots: Vec::new(),
32 img_byte: Vec::new(),
33 image_type: String::new(),
34 }
35 }
36
37 pub fn set_img_byte(&mut self, data: Vec<u8>) {
39 self.img_byte = data;
40 }
41
42 pub fn set_image_type(&mut self, image_type: impl Into<String>) {
44 self.image_type = image_type.into();
45 }
46
47 pub fn add_stamp_annot(&mut self, annot: impl Into<String>) {
49 self.stamp_annots.push(annot.into());
50 }
51}
52
53#[allow(deprecated)]
54impl Default for StampAnnotVo {
55 fn default() -> Self {
56 Self::new()
57 }
58}
59
60#[allow(deprecated)]
61#[cfg(test)]
62mod tests {
63 #[allow(deprecated)]
64 use super::*;
65
66 #[test]
67 #[allow(deprecated)]
68 fn test_stamp_annot_vo_new() {
69 let vo = StampAnnotVo::new();
70 assert!(vo.stamp_annots.is_empty());
71 assert!(vo.img_byte.is_empty());
72 assert!(vo.image_type.is_empty());
73 }
74
75 #[test]
76 #[allow(deprecated)]
77 fn test_stamp_annot_vo_setters() {
78 let mut vo = StampAnnotVo::new();
79 vo.set_img_byte(vec![0x89, 0x50, 0x4E, 0x47]);
80 vo.set_image_type("PNG");
81 vo.add_stamp_annot("<StampAnnot/>");
82 assert_eq!(vo.img_byte.len(), 4);
83 assert_eq!(vo.image_type, "PNG");
84 assert_eq!(vo.stamp_annots.len(), 1);
85 }
86}