Skip to main content

tauri_plugin_thermal_printer/models/
print_job_request.rs

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