Crate steamworks

Crate steamworks 

Source
Expand description

§steamworks

crates.io Documentation License

This crate provides Rust bindings to the Steamworks SDK.

§Usage

Add the following to your Cargo.toml:

[dependencies]
steamworks = "0.12.0"
CrateSDKMSRV
git1.621.80.0
0.12.01.621.80.0
0.11.01.58a1.71.1
0.10.01.541.56.1
0.9.01.53a1.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_sockets and networking_messages.
networking_utils
screenshots
stats
timeline

Structs§

AccountId
A user’s account id
AppId
An id for a steam app/game
Apps
Access to the steam apps interface
AuthSessionTicketResponse
Called when generating a authentication session ticket.
AuthTicket
A handle for an authentication ticket that can be used to cancel it.
CallbackHandle
A handle that can be used to remove a callback at a later point.
Client
The main entry point into the steam client.
CreateQueryError
DownloadItemResult
FloatingGamepadTextInputDismissed
Friend
FriendFlags
FriendGame
Information about a friend’s current state in a game
Friends
Access to the steam friends interface
GSClientApprove
Called when a client has been approved to connect to this game server
GSClientDeny
Called when a user has been denied to connection to this game server
GSClientGroupStatus
Called when we have received the group status of a user
GSClientKick
Called when a user has been denied to connection to this game server
GameId
A game id
GameLobbyJoinRequested
GameOverlayActivated
GameRichPresenceJoinRequested
GameServerItem
GamepadTextInputDismissed
Input
Access to the steam input interface
InstallInfo
InvalidErrorCode
ItemState
Leaderboard
LeaderboardEntry
LeaderboardScoreUploaded
LobbyChatMsg
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.
LobbyChatUpdate
A lobby chat room state has changed, this is usually sent when a user has joined or left the lobby.
LobbyCreated
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).
LobbyDataUpdate
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.
LobbyEnter
Recieved upon attempting to enter a lobby. Lobby metadata is available to use immediately after receiving this.
LobbyId
LobbyKey
A wrapper for a lobby key string.
LobbyKeyTooLongError
LobbyListFilter
Filters for the lobbies to be returned from request_lobby_list.
Matchmaking
Access to the steam matchmaking interface
MatchmakingServers
Access to the steam MatchmakingServers interface
MicroTxnAuthorizationResponse
NearFilter
A filter used for near-value sorting in lobby filtering.
Networking
Access to the steam networking interface
NewUrlLaunchParameters
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.
NumberFilter
A filter used for numerical attribute comparison in lobby filtering.
P2PSessionConnectFail
P2PSessionRequest
Called when a user wants to communicate via p2p
PersonaChange
PersonaStateChange
PingCallbacks
PlayerDetailsCallbacks
PublishedFileId
Worshop item ID
QueryHandle
Query handle, to allow for more filtering.
QueryResult
Query result
QueryResults
Query results
RemotePlay
RemotePlayConnected
A remote play session was established
RemotePlayDisconnected
A remote play session was closed
RemotePlaySession
RemotePlaySessionId
RemoteStorage
Access to the steam remote storage interface
RemoteStoragePlatforms
Platform flags used with SteamFile::set_sync_platforms to restrict syncing to specific operating systems.
Server
The main entry point into the steam client for servers.
ServerListCallbacks
ServerListRequest
ServerRulesCallbacks
SteamFile
A handle for a possible steam cloud file
SteamFileInfo
Name and size information about a file in the steam cloud
SteamFileReader
A read handle for a steam cloud file
SteamFileWriter
A write handle for a steam cloud file
SteamId
A user’s steam id
SteamServerConnectFailure
Called when the connection to the Steam servers fails.
SteamServersConnected
Called when a connection to the Steam servers is made.
SteamServersDisconnected
Called when the connection to the Steam servers is lost.
StringFilter
A filter used for string based key value comparisons.
TicketForWebApiResponse
Called when generating a authentication session ticket for web api.
UGC
UpdateHandle
A handle to update a published item
UpdateWatchHandle
A handle to watch an update of a published item
User
Access to the steam user interface
UserAchievementIconFetched
Result of a request to retrieve the achievement icon if the icon was not available at the time of the function call.
UserAchievementStored
Result of a request to store the achievements on the server, or an “indicate progress” call. If both current_progress and max_progress are zero, that means the achievement has been fully unlocked.
UserStats
Access to the steam user interface
UserStatsReceived
Callback type after calling request_current_stats().
UserStatsStored
Callback triggered by store().
Utils
Access to the steam utils interface
ValidateAuthTicketResponse
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.
AuthSessionError
Errors from begin_authentication_session
AuthSessionValidateError
Errors from ValidateAuthTicketResponse
CallbackResult
A sum type over all possible callback results
ChatEntryType
ChatMemberStateChange
Flags describing how a users lobby state has changed. This is provided from LobbyChatUpdate.
ChatRoomEnterResponse
ComparisonFilter
DenyReason
Reason for when a client fails to join or is kicked from a game server.
DistanceFilter
FileType
FloatingGamepadTextInputMode
FriendState
GamepadTextInputLineMode
GamepadTextInputMode
InputType
LeaderboardDataRequest
LeaderboardDisplayType
LeaderboardSortMethod
LobbyType
The visibility of a lobby
NotificationPosition
OverlayToStoreFlag
PublishedFileVisibility
ReleaseError
SendType
The method used to send a packet
ServerMode
Used to set the mode that a gameserver will run in
ServerResponse
SteamAPIInitError
SteamDeviceFormFactor
SteamError
Covers errors that can be returned by the steamworks API
StringFilterKind
UGCContentDescriptorID
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.
UGCQueryType
UGCStatisticType
Available published item statistic types.
UGCType
Workshop item types to search for
UpdateStatus
UploadScoreMethod
UserHasLicense
Results from User::user_has_license_for_app
UserList
Available user-specific lists. Certain ones are only available to the currently logged in user.
UserListOrder
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§

Callback

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.

Type Aliases§

NearFilters
NumberFilters
SIResult
SResult
StringFilters