escpos_rust/printer/
printer_model.rs1use super::{PrinterProfile};
2use crate::{PrinterConnectionData, command::Font};
3
4pub enum PrinterModel {
8 ZKTeco,
10 TMT20
12}
13
14impl PrinterModel {
15 pub fn vp_id(&self) -> (u16, u16, Option<u8>) {
17 match self {
18 PrinterModel::ZKTeco => (0x6868, 0x0200, Some(0x02)),
19 PrinterModel::TMT20 => (0x04b8, 0x0e15, Some(0x01))
20 }
21 }
22
23 pub fn usb_profile(&self) -> PrinterProfile {
25 let (vendor_id, product_id, endpoint) = self.vp_id();
26 match self {
27 PrinterModel::ZKTeco => {
28 PrinterProfile {
29 printer_connection_data: PrinterConnectionData::Usb {
30 vendor_id,
31 product_id,
32 endpoint,
33 timeout: std::time::Duration::from_secs(2)
34 },
35 columns_per_font: vec![(Font::FontA, 32), (Font::FontB, 42)].into_iter().collect(),
36 width: 384
37 }
38 },
39 PrinterModel::TMT20 => {
40 PrinterProfile {
41 printer_connection_data: PrinterConnectionData::Usb {
42 vendor_id,
43 product_id,
44 endpoint,
45 timeout: std::time::Duration::from_secs(2)
46 },
47 columns_per_font: vec![(Font::FontA, 48)].into_iter().collect(),
48 width: 576
49 }
50 }
51 }
52 }
53}