# NATIVE (Rust) **Part of:** craftlabs-authorization-sdk **Build:** Cargo workspace (Rust 1.70+) ## STRUCTURE ``` native/ ├── craft-core/ # cdylib — exports craft_* C ABI │ ├── src/ │ │ ├── lib.rs # C entry points: craft_initialize, craft_activate, etc. │ │ ├── trait_provider.rs # Provider trait │ │ ├── security/ # anti_debug, obfuscation, integrity, string_encrypt, dynamic_api │ │ ├── provider_selfhosted/ # activate, license, heartbeat, cache, protocol │ │ ├── crypto.rs, device.rs, session.rs, error.rs, license.rs, heartbeat.rs │ │ └── ... │ └── tests/c_api_test.rs ├── craftlabs-auth-cli/ # CLI binary │ └── src/ │ ├── main.rs # status/activate/check/info/release/migrate commands │ ├── config.rs # Config loading │ └── platform_api.rs # Platform API client ├── Cargo.toml # Workspace root ├── build/Makefile # Alternative build wrapper └── .deprecated-cmake/ # Old CMake build (unused) ``` ## WHERE TO LOOK | Task | Location | |------|----------| | C ABI exports | `craft-core/src/lib.rs` | | Provider trait | `craft-core/src/trait_provider.rs` | | Self-hosted logic | `craft-core/src/provider_selfhosted/` | | Security (anti-debug, obfuscation) | `craft-core/src/security/` | | CLI commands | `craftlabs-auth-cli/src/main.rs` | | Platform API client | `craftlabs-auth-cli/src/platform_api.rs` | ## CONVENTIONS - **C ABI**: `extern "C"` + `#[no_mangle]`; all public functions prefixed `craft_` - **Provider trait**: `Provider` trait with `initialize`, `activate`, `check_license`, `heartbeat`, `release`, `close` - **Security module**: each concern in separate file under `security/` - **Error handling**: `error.rs` defines error types; `fn fail_result()` for C return ## ANTI-PATTERNS - **Do not** mix JNI/JNA Rust glue — bridge is Java-side via JNA - **Do not** use the deprecated CMake build under `.deprecated-cmake/`