This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
keygen-rs is an unofficial Rust SDK for integrating with the keygen.sh licensing service. It provides both end-user licensing functionality and administrative APIs for license management.
# Standard build and test
cargo build
cargo test --all-features --verbose
# Feature-specific testing
cargo test # license-key features only
cargo test --features token # admin features
cargo test --all-features # all features
# Linting & formatting
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
# Documentation
cargo doc --no-deps --all-features# Using devbox scripts
devbox run test # cargo test -- --show-output
devbox run build-docs # cargo docThe codebase uses Cargo feature flags for modularity:
license-key(default): End-user features (validation, activation)token: Administrative features (CRUD operations, user management)rustls(default): Uses rustls for TLSnative-tls: Alternative TLS backend
Public API Modules:
config.rs- Global configuration with thread-safe lazy static setuplicense.rs- Core license validation, verification, and managementmachine.rs- Machine activation, deactivation, and managementservice.rs- Service introspection and health checksentitlement.rs- License entitlement managementerrors.rs- Comprehensive error handling with thiserror
Admin Modules (token feature):
product.rs,policy.rs,user.rs,token.rs- Administrative CRUD operations
Internal Modules:
client.rs- HTTP client wrapper with authenticationverifier.rs- Ed25519 cryptographic signature verificationdecryptor.rs- License file decryptioncertificate.rs- Certificate handling
- Thread-safe global configuration using
lazy_static - Strongly-typed enums for all API options and states
- Feature-gated compilation to prevent misuse of admin functions
- Comprehensive error types with detailed context for licensing scenarios
- Offline capabilities with license file caching and fingerprint-based activation
- HTTP:
reqwestwith rustls-tls, 30-second timeout default - Async:
tokiowith full features - Serialization:
serde+serde_jsonfor JSON API communication - Cryptography:
ed25519-dalek,aes-gcm,sha2 - Time:
chronofor date/time handling
- Use
cargo test --all-featuresfor comprehensive testing - Examples in
examples/directory serve as integration tests - Recommend mocking Keygen API responses for CI/CD testing
- Unit tests focus on offline functionality and error handling
- Uses release-plz for automated semantic versioning
- Conventional commits drive version bumps:
feat:→ Minor versionfix:→ Patch versionfeat!:→ Major version
- Auto-generates changelogs and publishes to crates.io
- Main crate: Core keygen-rs library
- Tauri plugins:
packages/tauri-plugin-keygen-rs*for desktop app integration