1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! escposify - A ESC/POS driver for Rust
//!
//! ## Examples
//!
//! ### sample.rs
//!
//! Write to a temporary file using [device::File].
//! ```rust
//! use std::io;
//!
//! use escposify::device::File;
//! use escposify::printer::Printer;
//!
//! use tempfile::NamedTempFileOptions;
//!
//! fn main() -> io::Result<()> {
//!     let tempf = NamedTempFileOptions::new().create().unwrap();
//!
//!     let file = File::from(tempf);
//!     let mut printer = Printer::new(file, None, None);
//!
//!     printer
//!         .chain_font("C")?
//!         .chain_align("lt")?
//!         .chain_style("bu")?
//!         .chain_size(0, 0)?
//!         .chain_text("The quick brown fox jumps over the lazy dog")?
//!         .chain_text("敏捷的棕色狐狸跳过懒狗")?
//!         .chain_barcode("12345678", "EAN8", "", "", 0, 0)?
//!         .chain_feed(1)?
//!         .chain_cut(false)?
//!         .flush()
//! }
//! ```
//!
//! ### Printing to /dev/usb/lp0
//!
//! When writing to a file ensure that `File::options().append(true)` is set otherwise writing is not possible.
//! ```no_run
//! use std::fs::File;
//! use std::io;
//!
//! use escposify::printer::Printer;
//!
//! fn main() -> io::Result<()> {
//!     let device_file = File::options().append(true).open("/dev/usb/lp0").unwrap();
//!
//!     let file = escposify::device::File::from(device_file);
//!     let mut printer = Printer::new(file, None, None);
//!
//!     printer
//!         .chain_size(0,0)?
//!         .chain_text("The quick brown fox jumps over the lazy dog")?
//!         .chain_feed(1)?
//!         .chain_cut(false)?
//!         .flush()
//! }
//! ```
//!
//! ### Writing to the stdout
//!
//! Understandably not all options work here (alignment, fonts, chain_cut etc.)
//! but for quick debugging and prototyping this is a good option
//! as it saves tons of time when working on the logic of your implementation.
//!
//! ```rust
//! use std::io::{self, stdout};
//! use escposify::printer::Printer;
//!
//! fn main() -> io::Result<()> {
//!
//!     let mut printer = Printer::new(stdout(), None, None);
//!
//!     printer
//!         .chain_feed(2)?
//!         .chain_text("The quick brown fox jumps over the lazy dog")?
//!         .chain_text("敏捷的棕色狐狸跳过懒狗")?
//!         .chain_feed(1)?
//!         .flush()
//! }
//! ```
//!
//! ### Printing to a printer via USB
//!
//! ```no_run
//! use std::io;
//! use escposify::printer::Printer;
//! use escposify::device::Usb;
//!
//! fn main() -> io::Result<()> {
//!     let product_id = 0xa700;
//!     let vendor_id = 0x0525;
//!     let usb = Usb::new(vendor_id, product_id)?;
//!
//!     let mut printer = Printer::new(usb, None, None);
//!
//!     printer
//!         .chain_feed(5)?
//!         .chain_font("C")?
//!         .chain_align("lt")?
//!         .chain_style("bu")?
//!         .chain_size(0, 0)?
//!         .chain_text("The quick brown fox jumps over the lazy dog")?
//!         .chain_barcode("12345678", "EAN8", "", "", 0, 0)?
//!         .chain_feed(5)?
//!         .chain_cut(false)?
//!         .flush()
//! }
//! ```

pub mod consts;
pub mod device;
pub mod img;
pub mod printer;