rustify-licensing 0.1.0

Framework-agnostic in-app licensing (validate / machine-activate / offline-grace) for native Rust apps. Keygen provider + Bevy / egui / headless adapters.
Documentation
//! Drive the full licensing flow without a UI.
//!
//! ```sh
//! # Point at your Keygen account and pass a key:
//! KEYGEN_ACCOUNT=<uuid> RUSTIFY_DEMO_KEY=<license-key> \
//!   cargo run -p rustify-licensing --example headless
//! ```
//!
//! With no `RUSTIFY_DEMO_KEY` it just prints the (persisted) fingerprint and reports
//! `Locked` — no network call.

use rustify_licensing::adapters::headless::check_blocking;
use rustify_licensing::{KeygenProvider, LicenseConfig, LicenseState, StorageConfig};

fn main() {
    let storage = StorageConfig {
        path: std::env::temp_dir().join("rustify-demo-license.env"),
        dev_shadow: None,
        env_key_var: Some("RUSTIFY_DEMO_KEY".into()),
    };
    let config = LicenseConfig {
        // Your Keygen account id (a public UUID). Set it here or via KEYGEN_ACCOUNT.
        account_id: std::env::var("KEYGEN_ACCOUNT")
            .unwrap_or_else(|_| "YOUR_KEYGEN_ACCOUNT_ID".into()),
        api_base: "https://api.keygen.sh/v1".into(),
        grace_secs: 14 * 24 * 60 * 60,
        storage,
        buy_url: "https://example.com/#pricing".into(),
    };

    let provider = KeygenProvider::from_config(&config);
    let mut state = LicenseState::load(&config.storage);
    println!("fingerprint: {}", state.fingerprint);

    if state.key.trim().is_empty() {
        println!("no key set — export RUSTIFY_DEMO_KEY=<license-key> to test → status: Locked");
        return;
    }

    let status = check_blocking(&config, &provider, &mut state, |line| println!("  … {line}"));
    println!("status: {status:?}");
}