Expand description
Steam for Bevy, as opt-in features.
The kit’s core is one plugin, SteamKitPlugin, that owns the ONE Steam callback pump of the
process (SteamKitSystems::Pump, in First) and hands what it collected to every compiled
feature in the same frame (SteamKitSystems::Callbacks). Features:
lobby: Steam lobbies, rich presence (“Join Game” in the friends list), game invites and every friend-join path as Bevy messages (modulelobby, re-exported at the crate root).stats: the local user’s stats and achievements as Bevy messages, with batched stores (modulestats, re-exported at the crate root).leaderboards: find / create leaderboards, upload scores (queued and rate-limited), download entries (moduleleaderboards, re-exported at the crate root).auth: Steam Web API tickets for logging in to a game server (moduleauth, re-exported at the crate root).friends: the friends list with persona states, games and rich-presenceconnect, game invites with any connect string, raw join requests, avatars (modulefriends, re-exported at the crate root).overlay: open the Steam overlay (dialogs, store page, web page, invite dialogs) and learn when it opens and closes (moduleoverlay, re-exported at the crate root).steam: the real backend,RealSteamBackend, oversteamworks0.12.2. Without it the crate still builds (no Steam SDK runtime needed) andFakeSteamBackenddrives everything.
The kit is inert until a SteamBackendRes exists: insert
SteamBackendRes(Box::new(RealSteamBackend::new(client))) (feature steam) when Steam
initialised, or a FakeSteamBackend in tests. The game initialises Steam itself, keeps its own
steamworks::Client clone for any other Steam API, and never pumps it: exactly one
process_callbacks per frame for the whole process, and that is the kit’s.
When the Steam client quits while the game runs, the game keeps running: the kit writes
SteamLost once, stops pumping Steam and answers every Steam request with its feature’s
NoBackend error from then on.
Re-exports§
pub use auth::AuthBackend;authpub use auth::AuthError;authpub use auth::AuthErrorKind;authpub use auth::AuthRequest;authpub use auth::AuthRequestId;authpub use auth::AuthSettings;authpub use auth::FakeAuthFailure;authpub use auth::SteamAuth;authpub use auth::WebApiTicket;authpub use auth::WebApiTicketReady;authpub use friends::AvatarSize;friendspub use friends::ConnectRequested;friendspub use friends::ConnectSource;friendspub use friends::FriendAvatar;friendspub use friends::FriendGame;friendspub use friends::FriendInfo;friendspub use friends::FriendsBackend;friendspub use friends::FriendsChanged;friendspub use friends::FriendsError;friendspub use friends::FriendsErrorKind;friendspub use friends::FriendsRequestKind;friendspub use friends::FriendsSettings;friendspub use friends::GameInviteSent;friendspub use friends::InviteToGame;friendspub use friends::PersonaState;friendspub use friends::RefreshFriends;friendspub use friends::RequestUserInfo;friendspub use friends::SteamFriends;friendspub use friends::UserInfoReady;friendspub use friends::MAX_CONNECT_BYTES;friendspub use leaderboards::is_valid_leaderboard_name;leaderboardspub use leaderboards::FakeLeaderboardFailure;leaderboardspub use leaderboards::LeaderboardBackend;leaderboardspub use leaderboards::LeaderboardDisplay;leaderboardspub use leaderboards::LeaderboardEntry;leaderboardspub use leaderboards::LeaderboardError;leaderboardspub use leaderboards::LeaderboardErrorKind;leaderboardspub use leaderboards::LeaderboardFound;leaderboardspub use leaderboards::LeaderboardInfo;leaderboardspub use leaderboards::LeaderboardRequest;leaderboardspub use leaderboards::LeaderboardRequestId;leaderboardspub use leaderboards::LeaderboardSettings;leaderboardspub use leaderboards::LeaderboardSort;leaderboardspub use leaderboards::ScoreRange;leaderboardspub use leaderboards::ScoreUploaded;leaderboardspub use leaderboards::ScoresDownloaded;leaderboardspub use leaderboards::SteamLeaderboards;leaderboardspub use leaderboards::UploadMethod;leaderboardspub use leaderboards::MAX_LEADERBOARD_DETAILS;leaderboardspub use leaderboards::MAX_LEADERBOARD_NAME_BYTES;leaderboardspub use lobby::connect_string;lobbypub use lobby::parse_connect_lobby;lobbypub use lobby::ClearRichPresence;lobbypub use lobby::CreateLobby;lobbypub use lobby::InviteFriend;lobbypub use lobby::InviteSent;lobbypub use lobby::JoinLobby;lobbypub use lobby::JoinRequested;lobbypub use lobby::JoinSource;lobbypub use lobby::LeaveLobby;lobbypub use lobby::LobbyBackend;lobbypub use lobby::LobbyCreated;lobbypub use lobby::LobbyEntered;lobbypub use lobby::LobbyError;lobbypub use lobby::LobbyErrorKind;lobbypub use lobby::LobbyKind;lobbypub use lobby::LobbyLeft;lobbypub use lobby::LobbySettings;lobbypub use lobby::SetRichPresence;lobbypub use lobby::SteamLobby;lobbypub use lobby::MAX_LOBBY_MEMBERS;lobbypub use overlay::OpenOverlay;overlaypub use overlay::OverlayBackend;overlaypub use overlay::OverlayError;overlaypub use overlay::OverlayErrorKind;overlaypub use overlay::OverlayToggled;overlaypub use overlay::SteamOverlay;overlaypub use overlay::StoreFlag;overlaypub use stats::is_valid_api_name;statspub use stats::AchievementProgress;statspub use stats::AchievementUnlocked;statspub use stats::FakeStoreFailure;statspub use stats::StatKind;statspub use stats::StatValue;statspub use stats::StatsBackend;statspub use stats::StatsError;statspub use stats::StatsErrorKind;statspub use stats::StatsReady;statspub use stats::StatsRequest;statspub use stats::StatsSettings;statspub use stats::StatsStored;statspub use stats::SteamStats;statspub use stats::MAX_API_NAME_BYTES;stats
Modules§
- auth
auth - Feature
auth: Steam Web API tickets, so a game server can learn who the player is. - friends
friends - Feature
friends: the local user’s friends list (names, persona states, games, the rich-presenceconnectof friends in this game), game invites carrying any connect string, raw join requests, user info for non-friends and avatars as RGBA bytes. - leaderboards
leaderboards - Feature
leaderboards: find (or create) Steam leaderboards, upload scores, download entries. - lobby
lobby - Feature
lobby: Steam lobbies, rich presence, invites and friend-join requests. - overlay
overlay - Feature
overlay: open the Steam overlay (a dialog, a user’s page, a web page, the store page, the invite dialog) and learn when it opens and closes. - stats
stats - Feature
stats: Steam user stats and achievements.
Structs§
- Fake
Steam Backend - An in-memory Steam. Cheap to clone: every clone shares the same state, so a test keeps one
clone to inspect while the kit owns another inside
crate::SteamBackendRes. - Real
Steam Backend steam - The real Steam backend. Holds a
steamworks::Clientclone (which also keeps Steam alive). - Steam
Backend Res - The active backend. Insert it to make the kit live; without it every system is inert (and
feature requests are answered with a
NoBackenderror). When Steam is gone (crate::SteamLost) the kit keeps the resource but replaces the backend in it by an inert one (no pump, no feature; the identity queries still answer). - Steam
KitPlugin - The kit’s plugin. Add it ONCE; it adds no other plugin and works under
MinimalPlugins. - Steam
Lost - Steam is gone for this process: the Steam client quit or its process ended (or the backend’s
pump panicked and the kit caught it). Written once per backend, in
FirstafterSteamKitSystems::Callbacksof the frame it happened (readable in that frame’sPreUpdate/Update).
Enums§
- Backend
Event - A raw event produced by a backend’s
SteamBackend::pump. The kit collects them once per frame incrate::SteamKitSystems::Pumpand every compiled feature turns its own variants into public messages incrate::SteamKitSystems::Callbacks. - Fake
Call - One recorded call into the fake backend (queries such as
lobby_dataare not recorded). - Steam
KitSystems - The kit’s system sets.
#[non_exhaustive]: match with a_arm. - Steam
Lost Reason - Why Steam is gone (
BackendEvent::SteamLost,crate::SteamLost).#[non_exhaustive].
Traits§
- Steam
Backend - What the kit’s core needs from Steam, plus one accessor per optional feature. Implementations
must never panic; a failure is a
false/None/ an error event.
Functions§
- is_
individual_ steam_ id64 - Is
idan individual (user) SteamID64 in the public universe? Universeid >> 56 == 1, account type(id >> 52) & 0xF == 1, instance(id >> 32) & 0xFFFFF == 1, account idid as u32 != 0.