easyofd_reader/model/
seal_data_vo.rs1#[derive(Debug, Clone)]
9pub struct SealDataVo {
10 pub seal_id: String,
12 pub seal_name: Option<String>,
14 pub img_byte: Vec<u8>,
16 pub image_type: String,
18}
19
20impl SealDataVo {
21 #[must_use]
23 pub fn new(seal_id: impl Into<String>) -> Self {
24 Self {
25 seal_id: seal_id.into(),
26 seal_name: None,
27 img_byte: Vec::new(),
28 image_type: String::new(),
29 }
30 }
31
32 #[must_use]
34 pub fn with_name(mut self, name: impl Into<String>) -> Self {
35 self.seal_name = Some(name.into());
36 self
37 }
38
39 #[must_use]
41 pub fn with_img(mut self, data: Vec<u8>, image_type: impl Into<String>) -> Self {
42 self.img_byte = data;
43 self.image_type = image_type.into();
44 self
45 }
46}
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_seal_data_vo_new() {
54 let vo = SealDataVo::new("seal_001");
55 assert_eq!(vo.seal_id, "seal_001");
56 assert!(vo.seal_name.is_none());
57 assert!(vo.img_byte.is_empty());
58 }
59
60 #[test]
61 fn test_seal_data_vo_with_name() {
62 let vo = SealDataVo::new("seal_001").with_name("Company Seal");
63 assert_eq!(vo.seal_name.as_deref(), Some("Company Seal"));
64 }
65
66 #[test]
67 fn test_seal_data_vo_with_img() {
68 let data = vec![0x89, 0x50, 0x4E, 0x47];
69 let vo = SealDataVo::new("seal_001").with_img(data.clone(), "PNG");
70 assert_eq!(vo.img_byte, data);
71 assert_eq!(vo.image_type, "PNG");
72 }
73}