tauri_plugin_thermal_printer/models/
print_sections.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub enum PrintSections {
5 Title(Title),
6 Subtitle(Subtitle),
7 Text(Text),
8 Feed(Feed),
9 Cut(Cut),
10 Beep(Beep),
11 Drawer(Drawer),
12 GlobalStyles(GlobalStyles),
13 Qr(Qr),
14 Barcode(Barcode),
15 Table(Table),
16 DataMatrix(DataMatrixModel),
17 Pdf417(Pdf417),
18 Image(Image),
19 Logo(Logo),
20 Line(Line),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct Title {
25 pub text: String,
26 pub styles: Option<GlobalStyles>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct Subtitle {
31 pub text: String,
32 pub styles: Option<GlobalStyles>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct Text {
37 pub text: String,
38 pub styles: Option<GlobalStyles>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct Feed {
43 pub feed_type: String,
44 pub value: u8,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct Cut {
49 pub mode: String,
50 pub feed: u8,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct Beep {
55 pub times: u8,
56 pub duration: u8,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct Drawer {
61 pub pin: u8,
62 pub pulse_time: u16,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct GlobalStyles {
67 pub bold: Option<bool>,
68 pub underline: Option<bool>,
69 pub align: Option<String>,
70 pub italic: Option<bool>,
71 pub invert: Option<bool>,
72 pub font: Option<String>,
73 pub rotate: Option<bool>,
74 pub upside_down: Option<bool>,
75 pub size: Option<String>,
76}
77
78impl Default for GlobalStyles {
79 fn default() -> Self {
80 Self {
81 bold: Some(false),
82 underline: Some(false),
83 align: Some("left".to_string()),
84 italic: Some(false),
85 invert: Some(false),
86 font: Some("A".to_string()),
87 rotate: Some(false),
88 upside_down: Some(false),
89 size: Some("normal".to_string()),
90 }
91 }
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
95pub struct Table {
96 pub columns: u8,
97 pub column_widths: Option<Vec<u8>>,
98 pub header: Option<Vec<Text>>,
99 pub body: Vec<Vec<Text>>,
100 pub truncate: bool,
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct Qr {
105 pub data: String,
106 pub size: u8,
107 pub error_correction: String,
108 pub model: u8,
109 pub align: Option<String>,
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
113pub struct Barcode {
114 pub data: String,
115 pub barcode_type: String,
116 pub width: u8,
117 pub height: u8,
118 pub text_position: String,
119 pub align: Option<String>,
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct DataMatrixModel {
124 pub data: String,
125 pub size: u8,
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
129pub struct Pdf417 {
130 pub data: String,
131 pub columns: u8,
132 pub rows: u8,
133 pub width: u8,
134 pub height: u8,
135 pub error_correction: u8,
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
139pub struct Image {
140 pub data: String,
141 pub max_width: i32,
142 pub align: String,
143 pub dithering: bool,
144 pub size: String,
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct Logo {
149 pub key_code: u8,
150 pub mode: String,
151}
152
153#[derive(Debug, Clone, Serialize, Deserialize)]
154pub struct Line {
155 pub character: String,
156}