dan335 / steamworks-rs

Rust bindings to the SteamWorks SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.9.0"

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.

About

Rust bindings to the SteamWorks SDK

License:Apache License 2.0


Languages

Language:Rust 100.0%Language:Makefile 0.0%