Expand description
The epson crate contains Rust bindings to the Epson Point of Sale (POS) thermal printers’ printer format.
Currently, this library supports a limited number of commands, and some
basic interfaces for both synchronous Rust as well as async
Rust through tokio, behind the tokio
feature.
Docs can be found on docs.rs, and information about the latest release can be found on crates.io.
§Supported Models
Specific makes/models of thermal printers will be added as I either get my hands on them, or someone maintains the model for the package. If your make/model isn’t supported, you can use models::Model::Generic.
Model | Type | Description |
---|---|---|
T20II | models::Model::T20II | Epson TM-T20II Thermal Printer |
T30II | models::Model::T30II | Epson TM-T30II Thermal Printer |
§Writing to a std::io::Write
We can write to a std::io::Write
traited object (such as a TcpStream
,
but maybe something like a Serial device?), you can use a Writer to
handle writing commands to the printer.
// IP address of the printer
let stream = TcpStream::connect("192.168.0.12:9100").unwrap();
let mut pos = epson::Writer::open(Model::T20II, Box::new(stream)).unwrap();
pos.speed(5).unwrap();
pos.write_all(b"HACK THE PLANET\n").unwrap();
pos.feed(5).unwrap();
pos.cut().unwrap();
§Writing to a tokio::io::AsyncWrite
In addition to the std::io
support, the epson
crate also contains
tokio
support to write to a tokio::io::AsyncWrite
using an
[AsyncWriter].
This requires the tokio
feature.
let stream = TcpStream::connect("192.168.0.12:9100").await.unwrap();
let mut pos = epson::Writer::open(Model::T20II, Box::new(stream)).await.unwrap();
pos.speed(5).await.unwrap();
pos.write_all(b"HACK THE PLANET\n").await.unwrap();
pos.feed(5).await.unwrap();
pos.cut().await.unwrap();
Structs§
- Writer
- Writer to be used in order to communicate with an Epson brand thermal printer.
Enums§
- Alignment
- Possible horizontal alignments.
- Async
Writer Error tokio
- All possible errors that can be returned from the AsyncWriter struct.
- Barcode
- Supported barcode types
- Character
Set - CharacterSet are the codepages that can be set
- Command
- All commands that can be encoded to control an Epson printer.
- Error
- Possible error states that we can get returned from the crate
- HriPosition
- Position of HRI (Human Readable Interpretation) characters for barcodes.
- Model
- Maintained and understood models of Epson Printers.
Traits§
- Async
Writer Ext tokio
- Trait to add async epson methods.
- StdWriter
Ext - Trait to add std sync epson methods.