arcane-sdk 0.15.0

Arcane Powered game SDK core (ownership tickets, DRM checks)
Documentation
//! Manual end-to-end check against a real Arcane desktop app.
//!
//! ```bash
//! ARCANE_GAME_ID=9a1f8c3e-4b27-4d1a-9f6e-2c8b5d70a413 cargo run --example client_init
//! ```
//!
//! It renders a fake three-second loop calling `frame()`, prints the session
//! snapshot, then ends the session with `shutdown()`.
//!
//! The launch environment, set by Arcane Powered in production and by you when
//! you run the game by hand:
//!
//! - `ARCANE_GAME_ID`       the game id of your title in the Arcane portal
//! - `ARCANE_USER_ID`       the signed-in account (optional — `session.json` otherwise)
//!
//! Useful environment overrides (developer tooling — never set these in a game):
//!
//! - `ARCANE_DRM_ROOT`      point the SDK at a throwaway DRM directory
//! - `ARCANE_SDK_PORT`      talk to a stub or non-default loopback port
//! - `ARCANE_OFFLINE_ONLY`  never contact or launch Arcane desktop

use std::process::ExitCode;
use std::thread;
use std::time::Duration;

use arcane_sdk::ArcaneClient;

fn main() -> ExitCode {
    match ArcaneClient::init() {
        Ok(client) => {
            println!("ownership   {}", client.ownership());
            println!("owned       {}", client.is_owned());
            println!("game_id     {}", client.game_id());
            println!("user_id     {:?}", client.user_id());
            println!("device_hash {}", client.device_hash());
            println!("expires_at  {:?}", client.ticket_expires_at());
            println!("checked_at  {}", client.checked_at());

            client.set_graphics("2560x1440", "high");

            for _ in 0..600 {
                client.frame();
                thread::sleep(Duration::from_millis(5));
            }

            let session = client.session();
            println!();
            println!("tracking    {}", session.tracking);
            println!("session_id  {:?}", session.session_id);
            println!("played_secs {}", session.played_seconds);
            println!("sampling    {}", session.fps_sampling);
            println!("samples     {}", session.samples_taken);
            println!("last_fps    {:?}", session.last_fps_avg);

            client.shutdown();
            ExitCode::SUCCESS
        }
        Err(err) => {
            eprintln!("init failed: {err}");
            eprintln!();
            eprintln!("code      {}", err.code());
            eprintln!("message   {}", err.message());
            eprintln!("hint      {}", err.hint().unwrap_or("—"));
            eprintln!("retryable {}", err.is_retryable());
            for (key, value) in err.context() {
                eprintln!("  {key} = {value}");
            }
            eprintln!();
            eprintln!("json      {}", err.to_json());
            ExitCode::FAILURE
        }
    }
}