#steam #gamedev

steamworks

Provides rust friendly bindings to the steamworks sdk

14 releases (7 breaking)

0.8.0 Nov 23, 2021
0.7.0 Feb 27, 2021
0.6.1 Jan 25, 2020
0.5.1 Jun 6, 2019
0.3.0 Mar 1, 2018

#28 in Game dev

Download history 25/week @ 2021-10-02 23/week @ 2021-10-09 20/week @ 2021-10-16 17/week @ 2021-10-23 21/week @ 2021-10-30 26/week @ 2021-11-06 5/week @ 2021-11-13 36/week @ 2021-11-20 16/week @ 2021-11-27 32/week @ 2021-12-04 42/week @ 2021-12-11 44/week @ 2021-12-18 13/week @ 2021-12-25 29/week @ 2022-01-01 39/week @ 2022-01-08 53/week @ 2022-01-15

139 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

1.5MB
36K SLoC

steamworks

crates.io Documentation License

This crate provides rust friendly bindings to the steamworks sdk.

Usage

Add the following to your Cargo.toml:

[dependencies]
steamworks = "0.7.0"

Ensure that your computer has all the needed requirements to use bindgen.

Download and install the steamworks sdk and set the environment variable STEAM_SDK_LOCATION to point to it. This is currently built against steamworks v151.

Example

You can find more examples in examples.

use steamworks::AppId;
use steamworks::Client;
use steamworks::FriendFlags;
use steamworks::PersonaStateChange;

fn main() {
    let (client, single) = 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 {
        single.run_callbacks();
        ::std::thread::sleep(::std::time::Duration::from_millis(100));
    }
}

Features

serde: This feature enables serialization and deserialization of some types with serde.

License

This crate is dual-licensed under Apache and MIT.

Dependencies

~0.3–2.2MB
~49K SLoC

a