Skip to main content

Crate bevy_steam_kit

Crate bevy_steam_kit 

Source
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 (module lobby, re-exported at the crate root).
  • stats: the local user’s stats and achievements as Bevy messages, with batched stores (module stats, re-exported at the crate root).
  • leaderboards: find / create leaderboards, upload scores (queued and rate-limited), download entries (module leaderboards, re-exported at the crate root).
  • auth: Steam Web API tickets for logging in to a game server (module auth, re-exported at the crate root).
  • friends: the friends list with persona states, games and rich-presence connect, game invites with any connect string, raw join requests, avatars (module friends, 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 (module overlay, re-exported at the crate root).
  • steam: the real backend, RealSteamBackend, over steamworks 0.12.2. Without it the crate still builds (no Steam SDK runtime needed) and FakeSteamBackend drives 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;auth
pub use auth::AuthError;auth
pub use auth::AuthErrorKind;auth
pub use auth::AuthRequest;auth
pub use auth::AuthRequestId;auth
pub use auth::AuthSettings;auth
pub use auth::FakeAuthFailure;auth
pub use auth::SteamAuth;auth
pub use auth::WebApiTicket;auth
pub use auth::WebApiTicketReady;auth
pub use friends::AvatarSize;friends
pub use friends::ConnectRequested;friends
pub use friends::ConnectSource;friends
pub use friends::FriendAvatar;friends
pub use friends::FriendGame;friends
pub use friends::FriendInfo;friends
pub use friends::FriendsBackend;friends
pub use friends::FriendsChanged;friends
pub use friends::FriendsError;friends
pub use friends::FriendsErrorKind;friends
pub use friends::FriendsRequestKind;friends
pub use friends::FriendsSettings;friends
pub use friends::GameInviteSent;friends
pub use friends::InviteToGame;friends
pub use friends::PersonaState;friends
pub use friends::RefreshFriends;friends
pub use friends::RequestUserInfo;friends
pub use friends::SteamFriends;friends
pub use friends::UserInfoReady;friends
pub use friends::MAX_CONNECT_BYTES;friends
pub use leaderboards::is_valid_leaderboard_name;leaderboards
pub use leaderboards::FakeLeaderboardFailure;leaderboards
pub use leaderboards::LeaderboardBackend;leaderboards
pub use leaderboards::LeaderboardDisplay;leaderboards
pub use leaderboards::LeaderboardEntry;leaderboards
pub use leaderboards::LeaderboardError;leaderboards
pub use leaderboards::LeaderboardErrorKind;leaderboards
pub use leaderboards::LeaderboardFound;leaderboards
pub use leaderboards::LeaderboardInfo;leaderboards
pub use leaderboards::LeaderboardRequest;leaderboards
pub use leaderboards::LeaderboardRequestId;leaderboards
pub use leaderboards::LeaderboardSettings;leaderboards
pub use leaderboards::LeaderboardSort;leaderboards
pub use leaderboards::ScoreRange;leaderboards
pub use leaderboards::ScoreUploaded;leaderboards
pub use leaderboards::ScoresDownloaded;leaderboards
pub use leaderboards::SteamLeaderboards;leaderboards
pub use leaderboards::UploadMethod;leaderboards
pub use leaderboards::MAX_LEADERBOARD_DETAILS;leaderboards
pub use leaderboards::MAX_LEADERBOARD_NAME_BYTES;leaderboards
pub use lobby::connect_string;lobby
pub use lobby::parse_connect_lobby;lobby
pub use lobby::ClearRichPresence;lobby
pub use lobby::CreateLobby;lobby
pub use lobby::InviteFriend;lobby
pub use lobby::InviteSent;lobby
pub use lobby::JoinLobby;lobby
pub use lobby::JoinRequested;lobby
pub use lobby::JoinSource;lobby
pub use lobby::LeaveLobby;lobby
pub use lobby::LobbyBackend;lobby
pub use lobby::LobbyCreated;lobby
pub use lobby::LobbyEntered;lobby
pub use lobby::LobbyError;lobby
pub use lobby::LobbyErrorKind;lobby
pub use lobby::LobbyKind;lobby
pub use lobby::LobbyLeft;lobby
pub use lobby::LobbySettings;lobby
pub use lobby::SetRichPresence;lobby
pub use lobby::SteamLobby;lobby
pub use lobby::MAX_LOBBY_MEMBERS;lobby
pub use overlay::OpenOverlay;overlay
pub use overlay::OverlayBackend;overlay
pub use overlay::OverlayError;overlay
pub use overlay::OverlayErrorKind;overlay
pub use overlay::OverlayToggled;overlay
pub use overlay::SteamOverlay;overlay
pub use overlay::StoreFlag;overlay
pub use stats::is_valid_api_name;stats
pub use stats::AchievementProgress;stats
pub use stats::AchievementUnlocked;stats
pub use stats::FakeStoreFailure;stats
pub use stats::StatKind;stats
pub use stats::StatValue;stats
pub use stats::StatsBackend;stats
pub use stats::StatsError;stats
pub use stats::StatsErrorKind;stats
pub use stats::StatsReady;stats
pub use stats::StatsRequest;stats
pub use stats::StatsSettings;stats
pub use stats::StatsStored;stats
pub use stats::SteamStats;stats
pub use stats::MAX_API_NAME_BYTES;stats

Modules§

authauth
Feature auth: Steam Web API tickets, so a game server can learn who the player is.
friendsfriends
Feature friends: the local user’s friends list (names, persona states, games, the rich-presence connect of friends in this game), game invites carrying any connect string, raw join requests, user info for non-friends and avatars as RGBA bytes.
leaderboardsleaderboards
Feature leaderboards: find (or create) Steam leaderboards, upload scores, download entries.
lobbylobby
Feature lobby: Steam lobbies, rich presence, invites and friend-join requests.
overlayoverlay
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.
statsstats
Feature stats: Steam user stats and achievements.

Structs§

FakeSteamBackend
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.
RealSteamBackendsteam
The real Steam backend. Holds a steamworks::Client clone (which also keeps Steam alive).
SteamBackendRes
The active backend. Insert it to make the kit live; without it every system is inert (and feature requests are answered with a NoBackend error). 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).
SteamKitPlugin
The kit’s plugin. Add it ONCE; it adds no other plugin and works under MinimalPlugins.
SteamLost
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 First after SteamKitSystems::Callbacks of the frame it happened (readable in that frame’s PreUpdate / Update).

Enums§

BackendEvent
A raw event produced by a backend’s SteamBackend::pump. The kit collects them once per frame in crate::SteamKitSystems::Pump and every compiled feature turns its own variants into public messages in crate::SteamKitSystems::Callbacks.
FakeCall
One recorded call into the fake backend (queries such as lobby_data are not recorded).
SteamKitSystems
The kit’s system sets. #[non_exhaustive]: match with a _ arm.
SteamLostReason
Why Steam is gone (BackendEvent::SteamLost, crate::SteamLost). #[non_exhaustive].

Traits§

SteamBackend
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 id an individual (user) SteamID64 in the public universe? Universe id >> 56 == 1, account type (id >> 52) & 0xF == 1, instance (id >> 32) & 0xFFFFF == 1, account id id as u32 != 0.