Skip to main content

Code reference

This section documents every public item in the steamlogger crate, module by module: signatures, behaviour, error cases, invariants and the tests that cover them.

Cargo.toml
[package]
name = "steamlogger"
version = "0.1.0"
edition = "2021"
license = "MIT"

[lib]
name = "steamlogger"
path = "src/lib.rs"

[[bin]]
name = "steamlogger"
path = "src/main.rs"

The crate builds both a library and a binary from the same source tree. The library is the reusable part; the binary is one way to wire it together.

Crate map​

src/lib.rs
pub mod a2s;
pub mod config;
pub mod enrich;
pub mod model;
pub mod steam; // pub mod api; pub mod client;
pub mod storage;
pub mod tracker;
ModulePageLines (incl. tests)Role
(binary)main98Poll loop, wiring, signal handling
configconfig263TOML + environment → Config
modelmodel40LogEntry, GameLog serde types
trackertracker259Session state machine
enrichenrich190Friends, lobby, server/map matching
storagestorage210Atomic JSON read/write
a2sa2s331A2S_INFO UDP client
steam::apisteam::api334URLs, raw/domain types, parsers
steam::clientsteam::client125Blocking HTTP client

Complete public API index​

Types​

ItemKindModuleSummary
ConfigstructconfigFully resolved runtime configuration
RawConfigstructconfigRaw TOML shape with defaults
LogEntrystructmodelOne recorded session
GameLogstructmodelRoot object: { "games": [...] }
TrackerstructtrackerSession state machine + in-memory log
SessionEventenumtrackerStarted / Running / Ended / Idle
EnrichmentstructenrichBest-effort extras for one tick
ServerInfostructa2sServer name + current map
A2sClientstructa2sUDP A2S_INFO query client
CurrentGamestructsteam::apiThe game a player is running
Friendstructsteam::apiA friend-list entry
PlayerSummarystructsteam::apiA GetPlayerSummaries row
PlayerSummariesResponsestructsteam::apiRaw JSON envelope
PlayerSummariesBodystructsteam::apiRaw JSON body
RawPlayerSummarystructsteam::apiRaw player row
FriendListResponsestructsteam::apiRaw JSON envelope
FriendListBodystructsteam::apiRaw JSON body
RawFriendstructsteam::apiRaw friend row
SteamClientstructsteam::clientBlocking Steam Web API client

Functions and methods​

ItemSignature (abridged)Module
config::loadfn load(path: &Path) -> anyhow::Result<Config>config
config::example_configfn example_config() -> Stringconfig
LogEntry::newfn new(name: String, start: String) -> Selfmodel
Tracker::newfn new(log: GameLog) -> Selftracker
Tracker::updatefn update(&mut self, game: &CurrentGame, now: &str) -> SessionEventtracker
Tracker::end_activefn end_active(&mut self, now: &str) -> SessionEventtracker
Tracker::apply_metafn apply_meta(&mut self, index, map, server, playing, lobby) -> anyhow::Result<()>tracker
Tracker::logfn log(&self) -> &GameLogtracker
Tracker::into_logfn into_log(self) -> GameLogtracker
Tracker::active_indexfn active_index(&self) -> Option<usize>tracker
enrich::analyzefn analyze(client, a2s, me, game) -> Enrichmentenrich
enrich::same_game_friendsfn same_game_friends(&[PlayerSummary], &CurrentGame) -> Vec<String>enrich
enrich::lobby_friendsfn lobby_friends(&[PlayerSummary], &CurrentGame) -> Vec<String>enrich
enrich::server_and_mapfn server_and_map(&mut A2sClient, &CurrentGame) -> (Option<String>, Option<String>)enrich
storage::read_logfn read_log(path: &Path) -> anyhow::Result<GameLog>storage
storage::write_logfn write_log(path: &Path, log: &GameLog) -> anyhow::Result<()>storage
A2sClient::newfn new() -> Selfa2s
A2sClient::queryfn query(&mut self, addr: &str) -> anyhow::Result<ServerInfo>a2s
api::summary_to_current_gamefn summary_to_current_game(&PlayerSummary) -> Option<CurrentGame>steam::api
api::player_summaries_urlfn player_summaries_url(key: &str, ids: &[u64]) -> Stringsteam::api
api::friend_list_urlfn friend_list_url(key: &str, steam_id: u64) -> Stringsteam::api
api::parse_player_summariesfn parse_player_summaries(json: &str) -> anyhow::Result<Vec<PlayerSummary>>steam::api
api::parse_friendsfn parse_friends(json: &str) -> anyhow::Result<Vec<Friend>>steam::api
api::entry_to_jsonfn entry_to_json(entry: &LogEntry) -> Stringsteam::api
SteamClient::newfn new(key: String) -> Selfsteam::client
SteamClient::with_timeoutfn with_timeout(key: String, timeout: Duration) -> Selfsteam::client
SteamClient::current_gamefn current_game(&self, steam_id: u64) -> anyhow::Result<Option<CurrentGame>>steam::client
SteamClient::friendsfn friends(&self, steam_id: u64) -> anyhow::Result<Vec<Friend>>steam::client
SteamClient::summariesfn summaries(&self, ids: &[u64]) -> anyhow::Result<Vec<PlayerSummary>>steam::client

:::tip This index is enforced npm run check:api in website/ scans src/**/*.rs for pub items and fails if any of them is missing from these reference pages. See Documentation workflow. :::

Conventions used in this reference​

  • Signatures are copied verbatim from the source; self receivers show mutability exactly as declared.
  • Errors sections list the anyhow context strings you will actually see on stderr.
  • Panics sections exist only where the code can panic (there are two such places in the crate, both documented).
  • Private helpers are documented when they carry meaningful behaviour — Tracker::close_at, storage::temp_path, a2s::parse_cstr, client::chunks — and marked (private).

Dependencies​

CrateVersionUsed for
anyhow1Error type and .context() messages everywhere
chrono0.4 (serde)RFC 3339 local timestamps in main::now
ctrlc3SIGINT handler
reqwest0.12 (blocking, json, rustls-tls, no default features)HTTPS to the Steam Web API
serde1 (derive)Config and log (de)serialisation
serde_json1JSON parsing and pretty printing
toml0.8Config parsing

No async runtime, no OpenSSL, no database driver.