Skip to main content

tauri_plugin_thermal_printer/models/
print_job_request.rs

1use crate::models::paper_size::PaperSize;
2use crate::models::print_sections::PrintSections;
3use crate::commands_esc_pos::text::code_page::CodePage;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct PrintJobRequest {
8    /// Printer name (for system printing) or connection configuration
9    pub printer: String,
10    pub sections: Vec<PrintSections>,
11    pub options: CodePage,
12    pub paper_size: PaperSize,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct PrinterInfo {
17    pub name: String,
18    pub interface_type: String,
19    pub identifier: String, // IP:PORT, MAC address, or USB port
20    pub status: String,
21}
22
23#[derive(Debug, Deserialize, Serialize, Clone)]
24pub struct TestPrintRequest {
25    pub printer_info: PrintJobRequest,
26
27    // Secciones de prueba
28    #[serde(default = "default_true")]
29    pub include_text: bool,
30
31    #[serde(default = "default_false")]
32    pub include_custom_text: bool,
33
34    #[serde(default)]
35    pub custom_text: Option<String>,
36
37    #[serde(default = "default_true")]
38    pub include_text_styles: bool,
39
40    #[serde(default = "default_true")]
41    pub include_alignment: bool,
42
43    #[serde(default = "default_true")]
44    pub include_columns: bool,
45
46    #[serde(default = "default_true")]
47    pub include_separators: bool,
48
49    // Códigos
50    #[serde(default = "default_true")]
51    pub include_barcode: bool,
52
53    #[serde(default = "default_false")]
54    pub include_barcode_types: bool,
55
56    #[serde(default = "default_true")]
57    pub include_qr: bool,
58
59    // Imágenes
60    #[serde(default = "default_false")]
61    pub include_image: bool,
62
63    #[serde(default)]
64    pub image_base64: Option<String>,
65
66    // Control
67    #[serde(default = "default_true")]
68    pub include_beep: bool,
69
70    #[serde(default = "default_false")]
71    pub test_cash_drawer: bool,
72
73    #[serde(default = "default_true")]
74    pub cut_paper: bool,
75
76    #[serde(default = "default_true")]
77    pub test_feed: bool,
78
79    // Opciones avanzadas
80    #[serde(default = "default_false")]
81    pub test_all_fonts: bool,
82
83    #[serde(default = "default_false")]
84    pub test_invert: bool,
85
86    #[serde(default = "default_false")]
87    pub test_rotate: bool,
88}
89
90fn default_true() -> bool {
91    true
92}
93
94fn default_false() -> bool {
95    false
96}