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

§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::AsyncWriter::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§

Enums§

  • Possible horizontal alignments.
  • All commands that can be encoded to control an Epson printer.
  • Possible error states that we can get returned from the crate
  • Maintained and understood models of Epson Printers.