Crate barcode_scanner

source ·
Expand description

Scan 1D barcodes using a hand scanner for Rust.

The barcode-scanner crate provides an interface to USB barcode scanners on Linux. It is built on top of the evdev crate. It works with any barcode scanner that acts as a keyboard.

Currently supported features:

  • One BarcodeScanner struct for all USB hand scanners that operate as a keyboard.
  • Prevent other clients from receiving events from the selected device by grabbing it.
  • Read 1D barcode consisting of numbers and letters.
  • Omit special characters in a barcode.

Example

This example grabs a hand scanner and prints a barcode that is read.

   use barcode_scanner::BarcodeScanner;

   let mut scanner = BarcodeScanner::open("/dev/input/by-id/usb-USB_Adapter_USB_Device-event-kbd")?;
   loop {
       let barcode = scanner.read()?;
       println!("{}", barcode);
   }

Structs