ocrl-mock 0.1.0

Mock C ABI library for OCRL (Octopus Card Reader Library) - provides test implementations for payment terminal integration
Documentation
# OCRL Mock Library

A mock implementation of the OCRL (Octopus Card Reader Library) C ABI for testing purposes. This library provides a test-friendly simulation of payment terminal operations including card enquiry, deduction, and settlement functions.

## Installation

### From Crates.io

```bash
cargo add ocrl-mock
```

### From Source

```bash
git clone https://github.com/caiguanhao/ocrl-mock.git
cd ocrl-mock
cargo build --release
```

## Usage

### As a Dependency

Add this to your `Cargo.toml`:

```toml
[dependencies]
ocrl-mock = "0.1.0"
```

If you have the actual OCRL library (`libocrl.a`) for Linux x86_64 but need to develop and test on macOS or other systems:

```toml
[target.'cfg(not(all(target_os = "linux", target_arch = "x86_64")))'.dependencies]
ocrl-mock = "0.1.0"
```

**`build.rs` file** in your project root:

```rust
fn main() {
    if cfg!(all(target_os = "linux", target_arch = "x86_64")) {
        // Link against libocrl.a placed in the lib/ directory
        println!("cargo:rerun-if-changed=lib");
        println!("cargo:rustc-link-search=native=lib");
        println!("cargo:rustc-link-lib=static=ocrl");
    }
}
```

## Supported Commands

- `config.get` - Get device configuration
- `display.img` - Display image (resId 1-8)
- `scheme.enquiry` - Get available promotion schemes
- `trans.request` - Request transaction (card.enquiry, deduct, settle)
- `trans.perform` - Perform requested transaction
- `trans.cancel` - Cancel transaction

## Environment Variables

You can control the mock behavior using environment variables:

- `CARD=1` - Simulates invalid card error
- `CARD=2` - Simulates card with transaction history
- Default - Normal card with balance

## Error Codes

| Code | Description |
|------|-------------|
| `0`  | Success (communication succeeded) |
| `-1` | COM not opened |
| `-2` | Communication error with R/W |
| `-3` | responseJSON buffer size not enough |
| `-6` | Link busy |

## License

MIT

## Disclaimer

This is a mock library for testing purposes only. It does not connect to real hardware and should not be used in production environments where actual payment processing is required.