#barcode #qr #data-matrix #aztec #pdf417

bin+lib dbr

Dynamsoft's Barcode Reader SDK enables you to efficiently embed barcode reading functionality in your web, desktop or mobile application using just a few lines of code

4 releases

Uses old Rust 2015

0.1.3 Oct 16, 2018
0.1.2 Oct 16, 2018
0.1.1 Oct 16, 2018
0.1.0 Oct 16, 2018

#24 in #barcode

37 downloads per month

Custom license

6MB
148 lines

Contains (Windows DLL, 6MB) DynamsoftBarcodeReaderx64.dll, (static library, 28KB) platforms/win/DBRx64.lib

Dynamsoft Barcode Reader

crates.io version

FFI bindings to Dynamsoft Barcode Reader SDK.

License

Get the trial license.

Contact Us

https://www.dynamsoft.com/Company/Contact.aspx

Usage

Decode barcodes from an image file:

extern crate dbr;

use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::c_char;
use std::env;

use dbr::reader::*;

extern "C" fn callback(index: i32, barcode_type: *const c_char, barcode_value: *const c_char) {
    unsafe {
        println!(
            "Index {}, {}, {}",
            index,
            CStr::from_ptr(barcode_type).to_str().unwrap(),
            CStr::from_ptr(barcode_value).to_str().unwrap()
        );
    }
}

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() == 1 {
        println!("Please input an image file.");
        return
    }

    println!("Hello Dynamsoft Barcode Reader!");
    unsafe {
        register_callback(Some(callback));
        let image_file = CString::new(env::args().nth(1).expect("Missing argument")).unwrap();
        let license = CString::new("t0068NQAAAFKYHV9xSZDEThUtClXNzxXH9TLSj/vYcY8mSKa0RxaGw3qNynyAMJ9Ib8UPxzFsbAMIugqPO313BvfiOdmZFTY=").unwrap();
        c_decodeFile(image_file.as_ptr(), license.as_ptr());
    }

    println!("Bye!");
}

Rust barcode reader

How to Customize the Package

  1. Install Dynamsoft Barcode Reader.

  2. Get the source code;

  3. Copy Dynamsoft\Barcode Reader <version number>\Components\C_C++\Redist\x64\DynamsoftBarcodeReaderx64.dll to platforms\win\DynamsoftBarcodeReaderx64.dll.

    Copy Dynamsoft\Barcode Reader <version number>\Components\C_C++\Lib\DBRx64.lib to platforms\win\DBRx64.lib

  4. Add function definitions to reader.h and add function implementations to reader.c.

  5. Generate reader.rs with bindgen.

    cargo install bindgen
    cd src
    bindgen reader.h -o reader.rs
    
  6. Add the local package to your Rust project:

    [dependencies]
    dbr = { path = "../dbr" }
    

No runtime deps