17 个版本

0.1.0-alpha.82024年8月10日
0.1.0-alpha.62024年8月7日
0.1.0-alpha.22024年5月20日
0.0.10 2024年5月3日
0.0.8 2024年4月21日

#1056Web 编程

Download history 249/week @ 2024-04-19 16/week @ 2024-04-26 189/week @ 2024-05-03 187/week @ 2024-05-17 14/week @ 2024-05-24 74/week @ 2024-07-26 209/week @ 2024-08-02

每月283次下载

MIT 许可证

23KB
364 代码行

TSAR Rust SDK

TSAR 的官方 Rust SDK。我们的主要关注点是 Rust,因此此 SDK 将是最受维护的。

banner

示例导入

tsar-client = "0.1.0-alpha.7"

示例用法

use tsar_client::Client;

// Get these credentials from: https://tsar.cc/app/*/settings
const CLIENT_KEY: &str = "MFkwEwY...GAr/ITBqA==";
const APP_ID: &str = "00000000-0000-0000-0000-000000000000";

fn main() {
    let options = ClientOptions {
        app_id: APP_ID.to_string(),
        client_key: CLIENT_KEY.to_string(),
        debug_print: true,
        dashboard_hostname: None,
    };

    // Initialize the client
    let client = Client::init(options).expect("Authentication failed.");

    // If client formed successfully, then the user is authorized
    // Access user info directly from the client

    println!("User ID: {}", client.subscription.user.id);

    // All subscriptions have "tiers" which can be set through key options. Default tier is 0.

    if client.subscription.tier >= 3 {
      println!("Woah you're special.");
    }

    // Perform a heart-beat check to validate that the user session is still valid
    if client.validate().is_err() {
      // Client session is no longer valid
    }
}

想要贡献吗?

此 SDK 对社区贡献开放!所有拉取请求都将由我们的团队进行审查。

需要帮助吗?

如果您有任何问题,请加入我们的 discord 社区。有关其他联系方式,请 点击此处

依赖关系

~7–19MB
~298K SLoC