ai-cortex-sdk 0.1.1

Rust client SDK for AI Cortex server: PAT auth, device binding, software store, offline license (Ed25519), and auto-update (check-update pull + SSE push).
Documentation
use serde::Serialize;

/// 采集到的设备身份信息
#[derive(Debug, Clone)]
pub struct DeviceIdentity {
    /// 设备指纹(直接取 machine_uid),作为设备唯一标识上送服务端
    pub fingerprint: String,
    /// 设备原始信息(JSON 字符串,随请求上送,便于后台展示)
    pub info: String,
}

#[derive(Debug, Clone, Serialize)]
struct DeviceInfo {
    os: &'static str,
    machine_uid: String,
}

/// 采集当前机器的设备指纹。
///
/// 优先调用 `machine_uid`(Linux: /etc/machine-id,Windows: MachineGuid,macOS: IOPlatformUUID),
/// 直接以其返回值作为稳定指纹。采集失败时回退为固定占位串,保证链路不中断
/// (此场景下指纹稳定性下降,但不会阻塞心跳/绑定)。
pub fn collect() -> DeviceIdentity {
    let uid = machine_uid::get().unwrap_or_else(|_| "unknown-device".to_string());

    let info = DeviceInfo {
        os: std::env::consts::OS,
        machine_uid: uid.clone(),
    };
    let info_json = serde_json::to_string(&info).unwrap_or_else(|_| "{}".to_string());

    DeviceIdentity {
        fingerprint: uid,
        info: info_json,
    }
}