csgo_gsi2/lib.rs
1//! Helper library for the [CS:GO Game State Integration (GSI) API][gsi].
2//!
3//! Best used with the [tokio](https://tokio.rs/) async ecosystem.
4//!
5//! [gsi]: https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Game_State_Integration
6//!
7//! ## Usage
8//!
9//! Add this to your `Cargo.toml`:
10//!
11//! ```toml
12//! [dependencies]
13//! csgo-gsi2 = "0.3.4"
14//! tokio = { version = "1.20.1", features = ["full"] }
15//! ```
16//!
17//! ## Simple Example
18//!
19//! [examples/simple.rs](https://github.com/redsuitman/csgo-gsi2/blob/main/examples/simple.rs) Can be run with `cargo run --example simple`.
20//!
21//! ```no_run
22//! use csgo_gsi2::{GSIConfigBuilder, GSIServer, Subscription};
23//!
24//! #[tokio::main]
25//! async fn main() {
26//! let config = GSIConfigBuilder::new("csgo-gsi")
27//! .subscribe_multiple(Subscription::UNRESTRICTED)
28//! .build();
29//!
30//! let mut server = GSIServer::new(config, 3000);
31//! server.add_listener(|update| println!("Got an update {:#?}", update));
32//!
33//! server
34//! .run()
35//! .await
36//! .expect("server didn't start");
37//! }
38//! ```
39//!
40//! Check [examples/verbose.rs](https://github.com/redsuitman/csgo-gsi2/blob/main/examples/verbose.rs) for the verbose example. Can be run with `cargo run --example verbose`.
41//!
42//! ### Features
43//! * `autoinstall` - Automatically install the gamestate_integration_csgo-gsi.cfg in the csgo folder.
44
45#![deny(missing_docs)]
46#![doc(html_root_url = "https://docs.rs/csgo-gsi2/0.3.4")]
47
48#[macro_use]
49extern crate gotham_derive;
50
51mod config;
52mod error;
53mod install_dir;
54mod server;
55pub mod update;
56
57pub use config::{Subscription, GSIConfigBuilder, GSIConfig};
58pub use error::Error;
59pub use server::GSIServer;
60pub use update::Update;