Expand description
§steamworks
This crate provides Rust bindings to the Steamworks SDK.
§Usage
Add the following to your Cargo.toml:
[dependencies]
steamworks = "0.12.0"| Crate | SDK | MSRV |
|---|---|---|
| git | 1.62 | 1.80.0 |
| 0.12.0 | 1.62 | 1.80.0 |
| 0.11.0 | 1.58a | 1.71.1 |
| 0.10.0 | 1.54 | 1.56.1 |
| 0.9.0 | 1.53a | 1.56.1 |
§Example
You can find more examples in examples.
use steamworks::AppId;
use steamworks::Client;
use steamworks::FriendFlags;
use steamworks::PersonaStateChange;
fn main() {
let client = Client::init().unwrap();
let _cb = client.register_callback(|p: PersonaStateChange| {
println!("Got callback: {:?}", p);
});
let utils = client.utils();
println!("Utils:");
println!("AppId: {:?}", utils.app_id());
println!("UI Language: {}", utils.ui_language());
let apps = client.apps();
println!("Apps");
println!("IsInstalled(480): {}", apps.is_app_installed(AppId(480)));
println!("InstallDir(480): {}", apps.app_install_dir(AppId(480)));
println!("BuildId: {}", apps.app_build_id());
println!("AppOwner: {:?}", apps.app_owner());
println!("Langs: {:?}", apps.available_game_languages());
println!("Lang: {}", apps.current_game_language());
println!("Beta: {:?}", apps.current_beta_name());
let friends = client.friends();
println!("Friends");
let list = friends.get_friends(FriendFlags::IMMEDIATE);
println!("{:?}", list);
for f in &list {
println!("Friend: {:?} - {}({:?})", f.id(), f.name(), f.state());
friends.request_user_information(f.id(), true);
}
for _ in 0..50 {
client.run_callbacks();
::std::thread::sleep(::std::time::Duration::from_millis(100));
}
}§Features
serde: This feature enables serialization and deserialization of some types with serde.
image: This feature allows accessing image data like icons with image crate.
§License
This crate is dual-licensed under Apache and
MIT, except for the files in [steamworks-sys/lib/steam/]
§Help, I can’t run my game!
If you are seeing errors like STATUS_DLL_NOT_FOUND, Image not found etc. You are likely missing the Steamworks SDK Redistributable files. Steamworks-rs loads the SDK dynamically, so the libraries need to exist somewhere the operating system can find them. This is likely next to your game binary (.exe on windows). You can find the required files in the SDK release ZIP, under lib\steam\redistributable_bin. See #63 for further details
Re-exports§
pub use crate::timeline::*;
Modules§
- networking_
messages - The non-connection-oriented interface to send and receive messages (whether they be “clients” or “servers”).
- networking_
sockets - networking_
types - Types that are used by both
networking_socketsandnetworking_messages. - networking_
utils - screenshots
- stats
- timeline
Structs§
- Account
Id - A user’s account id
- AppId
- An id for a steam app/game
- Apps
- Access to the steam apps interface
- Auth
Session Ticket Response - Called when generating a authentication session ticket.
- Auth
Ticket - A handle for an authentication ticket that can be used to cancel it.
- Callback
Handle - A handle that can be used to remove a callback at a later point.
- Client
- The main entry point into the steam client.
- Create
Query Error - Download
Item Result - Floating
Gamepad Text Input Dismissed - Friend
- Friend
Flags - Friend
Game - Information about a friend’s current state in a game
- Friends
- Access to the steam friends interface
- GSClient
Approve - Called when a client has been approved to connect to this game server
- GSClient
Deny - Called when a user has been denied to connection to this game server
- GSClient
Group Status - Called when we have received the group status of a user
- GSClient
Kick - Called when a user has been denied to connection to this game server
- GameId
- A game id
- Game
Lobby Join Requested - Game
Overlay Activated - Game
Rich Presence Join Requested - Game
Server Item - Gamepad
Text Input Dismissed - Input
- Access to the steam input interface
- Install
Info - Invalid
Error Code - Item
State - Leaderboard
- Leaderboard
Entry - Leaderboard
Score Uploaded - Lobby
Chat Msg - A chat (text or binary) message for this lobby has been received. After getting this you must use GetLobbyChatEntry to retrieve the contents of this message.
- Lobby
Chat Update - A lobby chat room state has changed, this is usually sent when a user has joined or left the lobby.
- Lobby
Created - Result of our request to create a Lobby. At this point, the lobby has been joined and is ready for use, a LobbyEnter_t callback will also be received (since the local user is joining their own lobby).
- Lobby
Data Update - The lobby metadata has changed. If m_ulSteamIDMember is a user in the lobby, then use GetLobbyMemberData to access per-user details; otherwise, if m_ulSteamIDMember == m_ulSteamIDLobby, use GetLobbyData to access the lobby metadata.
- Lobby
Enter - Recieved upon attempting to enter a lobby. Lobby metadata is available to use immediately after receiving this.
- LobbyId
- Lobby
Key - A wrapper for a lobby key string.
- Lobby
KeyToo Long Error - Lobby
List Filter - Filters for the lobbies to be returned from
request_lobby_list. - Matchmaking
- Access to the steam matchmaking interface
- Matchmaking
Servers - Access to the steam MatchmakingServers interface
- Micro
TxnAuthorization Response - Near
Filter - A filter used for near-value sorting in lobby filtering.
- Networking
- Access to the steam networking interface
- NewUrl
Launch Parameters - Called after the user executes a steam url with command line or query parameters such as steam://run/
//?param1=value1;param2=value2;param3=value3; while the game is already running. - Number
Filter - A filter used for numerical attribute comparison in lobby filtering.
- P2PSession
Connect Fail - P2PSession
Request - Called when a user wants to communicate via p2p
- Persona
Change - Persona
State Change - Ping
Callbacks - Player
Details Callbacks - Published
File Id - Worshop item ID
- Query
Handle - Query handle, to allow for more filtering.
- Query
Result - Query result
- Query
Results - Query results
- Remote
Play - Remote
Play Connected - A remote play session was established
- Remote
Play Disconnected - A remote play session was closed
- Remote
Play Session - Remote
Play Session Id - Remote
Storage - Access to the steam remote storage interface
- Remote
Storage Platforms - Platform flags used with
SteamFile::set_sync_platformsto restrict syncing to specific operating systems. - Server
- The main entry point into the steam client for servers.
- Server
List Callbacks - Server
List Request - Server
Rules Callbacks - Steam
File - A handle for a possible steam cloud file
- Steam
File Info - Name and size information about a file in the steam cloud
- Steam
File Reader - A read handle for a steam cloud file
- Steam
File Writer - A write handle for a steam cloud file
- SteamId
- A user’s steam id
- Steam
Server Connect Failure - Called when the connection to the Steam servers fails.
- Steam
Servers Connected - Called when a connection to the Steam servers is made.
- Steam
Servers Disconnected - Called when the connection to the Steam servers is lost.
- String
Filter - A filter used for string based key value comparisons.
- Ticket
ForWeb ApiResponse - Called when generating a authentication session ticket for web api.
- UGC
- Update
Handle - A handle to update a published item
- Update
Watch Handle - A handle to watch an update of a published item
- User
- Access to the steam user interface
- User
Achievement Icon Fetched - Result of a request to retrieve the achievement icon if the icon was not available at the time of the function call.
- User
Achievement Stored - Result of a request to store the achievements on the server, or an “indicate progress” call.
If both
current_progressandmax_progressare zero, that means the achievement has been fully unlocked. - User
Stats - Access to the steam user interface
- User
Stats Received - Callback type after calling
request_current_stats(). - User
Stats Stored - Callback triggered by
store(). - Utils
- Access to the steam utils interface
- Validate
Auth Ticket Response - Called when an authentication ticket has been validated.
Enums§
- AppIDs
- AppID filter for queries. The “consumer” app is the app that the content is for. The “creator” app is a separate editor to create the content in, if applicable.
- Auth
Session Error - Errors from
begin_authentication_session - Auth
Session Validate Error - Errors from
ValidateAuthTicketResponse - Callback
Result - A sum type over all possible callback results
- Chat
Entry Type - Chat
Member State Change - Flags describing how a users lobby state has changed. This is provided from
LobbyChatUpdate. - Chat
Room Enter Response - Comparison
Filter - Deny
Reason - Reason for when a client fails to join or is kicked from a game server.
- Distance
Filter - File
Type - Floating
Gamepad Text Input Mode - Friend
State - Gamepad
Text Input Line Mode - Gamepad
Text Input Mode - Input
Type - Leaderboard
Data Request - Leaderboard
Display Type - Leaderboard
Sort Method - Lobby
Type - The visibility of a lobby
- Notification
Position - Overlay
ToStore Flag - Published
File Visibility - Release
Error - Send
Type - The method used to send a packet
- Server
Mode - Used to set the mode that a gameserver will run in
- Server
Response - SteamAPI
Init Error - Steam
Device Form Factor - Steam
Error - Covers errors that can be returned by the steamworks API
- String
Filter Kind - UGCContent
DescriptorID - Users can control what user-generated content they want to see under the Mature Content Filtering section in their preferences. This filtering is done automatically by Steam servers, but first, user-generated content must be tagged appropriately. Developers can use AddContentDescriptor and RemoveContentDescriptor calls to manage content descriptors a piece of UGC has. These can be retrieved from the result of a query via GetQueryUGCContentDescriptors.
- UGCQuery
Type - UGCStatistic
Type - Available published item statistic types.
- UGCType
- Workshop item types to search for
- Update
Status - Upload
Score Method - User
HasLicense - Results from
User::user_has_license_for_app - User
List - Available user-specific lists. Certain ones are only available to the currently logged in user.
- User
List Order - Query result sorting
Constants§
- QUERY_
PORT_ SHARED - Pass to SteamGameServer_Init to indicate that the same UDP port will be used for game traffic UDP queries for server browser pings and LAN discovery. In this case, Steam will not open up a socket to handle server browser queries, and you must use ISteamGameServer::HandleIncomingPacket and ISteamGameServer::GetNextOutgoingPacket to handle packets related to server discovery on your socket.
- RESULTS_
PER_ PAGE
Traits§
Functions§
- restart_
app_ if_ necessary - Returns true if the app wasn’t launched through steam and begins relaunching it, the app should exit as soon as possible.