Skip to main content

Crate tapsdk_pc

Crate tapsdk_pc 

Source
Expand description

High-level Rust bindings to TapTap PC SDK

This crate provides a safe, idiomatic Rust API for the TapTap PC SDK.

§Quick Start

use tapsdk_pc::{TapSdk, user, ownership, dlc};
use tapsdk_pc::callback::TapEvent;

fn main() -> tapsdk_pc::error::Result<()> {
    // Check if restart is needed (call before init)
    if tapsdk_pc::restart_app_if_necessary("your_client_id")? {
        // TapTap will relaunch the game, exit now
        return Ok(());
    }

    // Initialize the SDK
    let sdk = TapSdk::init("your_public_key")?;

    // Check game ownership
    if !ownership::is_game_owned() {
        println!("User does not own this game!");
        return Ok(());
    }

    // Request user authorization
    user::authorize("public_profile")?;

    // Game loop
    loop {
        // Poll for SDK events
        for event in sdk.run_callbacks() {
            match event {
                TapEvent::AuthorizeFinished(data) => {
                    if let Some(token) = data.token {
                        println!("User authorized! OpenID: {:?}", user::get_open_id());
                    }
                }
                TapEvent::SystemStateChanged(data) => {
                    println!("System state: {:?}", data.state);
                }
                _ => {}
            }
        }
         
        // ... your game logic ...
    }

    // SDK is automatically shut down when `sdk` is dropped
    Ok(())
}

Re-exports§

pub use callback::TapEvent;
pub use cloudsave::CloudSave;
pub use error::Result;
pub use error::TapSdkError;
pub use sdk::is_initialized;
pub use sdk::restart_app_if_necessary;
pub use sdk::TapSdk;
pub use tapsdk_pc_sys as sys;

Modules§

callback
Callback registry and event handling for TapTap PC SDK
cloudsave
Cloud save functionality
dlc
DLC (Downloadable Content) functionality
error
Error types for TapTap PC SDK
ownership
Game ownership functionality
sdk
Core SDK functionality
user
User authentication functionality