1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! # cs2-gsi
//!
//! Counter-Strike 2 **Game State Integration** listener for Rust.
//!
//! - **Async, single dependency surface** — built on `tokio` + `hyper` 1.x.
//! - **Strongly typed** model and events (no `serde_json::Value` in your code).
//! - **Drop-in cfg writer** — generate the right `gamestate_integration_*.cfg`
//! into the right place via Steam path discovery.
//! - **Event diffing** done for you: subscribe to `PlayerDied`,
//! `BombPlanted`, `RoundPhaseUpdated`, `KillFeed`, … instead of comparing
//! payloads by hand.
//!
//! ## Quick start
//!
//! ```no_run
//! use cs2_gsi::{events::PlayerDied, cfg::GsiCfg, GameStateListener};
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! // 1. Drop a gamestate_integration_*.cfg into the CS2 cfg dir.
//! #[cfg(feature = "steam-discover")]
//! GsiCfg::for_localhost("ImLag", 4000).write_to_cs2()?;
//!
//! // 2. Stand up the listener.
//! let listener = GameStateListener::new(4000);
//! listener.on(|e: &PlayerDied| {
//! println!("☠ {} died", e.player.name);
//! });
//! listener.start().await?;
//!
//! // ... run the rest of your app ...
//!
//! listener.stop().await?;
//! # Ok(()) }
//! ```
//!
//! ## How it works
//!
//! ```text
//! CS2 client Your app
//! ┌──────────┐ ┌───────────────┐
//! │ cfg file │── HTTP POST JSON ──────────▶│ GameStateList │
//! └──────────┘ │ (this lib) │
//! ▲ │ diff │
//! │ generate cfg │ ▼ │
//! └─────────────────────────────────│ typed events │
//! └───────────────┘
//! ```
//!
//! Every payload arrives as JSON, is parsed into a [`model::GameState`],
//! diffed against the previous one and turned into a stream of typed
//! events. Handlers run synchronously on the listener task — keep them
//! light or `tokio::spawn` from inside.
pub use crate;
pub use crateGameEvent;
pub use crateGameStateListener;
pub use crateGameState;