Skip to main content

tapsdk_pc/
lib.rs

1//! High-level Rust bindings to TapTap PC SDK
2//!
3//! This crate provides a safe, idiomatic Rust API for the TapTap PC SDK.
4//!
5//! # Quick Start
6//!
7//! ```no_run
8//! use tapsdk_pc::{TapSdk, user, ownership, dlc};
9//! use tapsdk_pc::callback::TapEvent;
10//!
11//! fn main() -> tapsdk_pc::error::Result<()> {
12//!     // Check if restart is needed (call before init)
13//!     if tapsdk_pc::restart_app_if_necessary("your_client_id")? {
14//!         // TapTap will relaunch the game, exit now
15//!         return Ok(());
16//!     }
17//!
18//!     // Initialize the SDK
19//!     let sdk = TapSdk::init("your_public_key")?;
20//!
21//!     // Check game ownership
22//!     if !ownership::is_game_owned() {
23//!         println!("User does not own this game!");
24//!         return Ok(());
25//!     }
26//!
27//!     // Request user authorization
28//!     user::authorize("public_profile")?;
29//!
30//!     // Game loop
31//!     loop {
32//!         // Poll for SDK events
33//!         for event in sdk.run_callbacks() {
34//!             match event {
35//!                 TapEvent::AuthorizeFinished(data) => {
36//!                     if let Some(token) = data.token {
37//!                         println!("User authorized! OpenID: {:?}", user::get_open_id());
38//!                     }
39//!                 }
40//!                 TapEvent::SystemStateChanged(data) => {
41//!                     println!("System state: {:?}", data.state);
42//!                 }
43//!                 _ => {}
44//!             }
45//!         }
46//!         
47//!         // ... your game logic ...
48//!         # break;
49//!     }
50//!
51//!     // SDK is automatically shut down when `sdk` is dropped
52//!     Ok(())
53//! }
54//! ```
55
56pub mod callback;
57pub mod cloudsave;
58pub mod dlc;
59pub mod error;
60pub mod ownership;
61pub mod sdk;
62pub mod user;
63
64// Re-export commonly used types at the crate root
65pub use callback::TapEvent;
66pub use cloudsave::CloudSave;
67pub use error::{Result, TapSdkError};
68pub use sdk::{is_initialized, restart_app_if_necessary, TapSdk};
69
70// Re-export the sys crate for advanced users
71pub use tapsdk_pc_sys as sys;