最近看了下Rust,作为系统编程语言,真的是很复杂。我计划做一个简单的Rust模块,用于调用Dynamsoft Barcode Reader SDK,然后打包发布到https://crates.io/。
制作发布Rust Crate包
创建Rust lib工程:
cargo new dbr --lib
在lib.rs
中添加:
pub mod reader;
reader
模块对应reader.rs
文件,所以需要创建reader.h
, reader.c
:
// reader.h
typedef struct Barcode {
char* barcode_type;
char* barcode_value;
} Barcode;
typedef __int32 int32_t;
typedef void (*RustCallback)(int32_t, const char *, const char *);
int32_t register_callback(RustCallback callback);
void c_decodeFile(const char *fileName, const char *pszLicense)<