Crate epson

Source
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.

ModelTypeDescription
T20IImodels::Model::T20IIEpson TM-T20II Thermal Printer
T30IImodels::Model::T30IIEpson 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.
AsyncWriterErrortokio
All possible errors that can be returned from the AsyncWriter struct.
Barcode
Supported barcode types
CharacterSet
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§

AsyncWriterExttokio
Trait to add async epson methods.
StdWriterExt
Trait to add std sync epson methods.