Struct steamworks::UserStats

source ·
pub struct UserStats<Manager> { /* private fields */ }
Expand description

Access to the steam user interface

Implementations§

source§

impl<Manager> UserStats<Manager>

source

pub fn find_leaderboard<F>(&self, name: &str, cb: F)
where F: FnOnce(Result<Option<Leaderboard>, SteamError>) + 'static + Send,

source

pub fn find_or_create_leaderboard<F>( &self, name: &str, sort_method: LeaderboardSortMethod, display_type: LeaderboardDisplayType, cb: F )
where F: FnOnce(Result<Option<Leaderboard>, SteamError>) + 'static + Send,

source

pub fn upload_leaderboard_score<F>( &self, leaderboard: &Leaderboard, method: UploadScoreMethod, score: i32, details: &[i32], cb: F )

source

pub fn download_leaderboard_entries<F>( &self, leaderboard: &Leaderboard, request: LeaderboardDataRequest, start: usize, end: usize, max_details_len: usize, cb: F )
where F: FnOnce(Result<Vec<LeaderboardEntry>, SteamError>) + 'static + Send,

source

pub fn get_leaderboard_display_type( &self, leaderboard: &Leaderboard ) -> Option<LeaderboardDisplayType>

Returns the display type of a leaderboard handle. Returns None if the leaderboard handle is invalid.

source

pub fn get_leaderboard_sort_method( &self, leaderboard: &Leaderboard ) -> Option<LeaderboardSortMethod>

Returns the sort method of a leaderboard handle. Returns None if the leaderboard handle is invalid.

source

pub fn get_leaderboard_name(&self, leaderboard: &Leaderboard) -> String

Returns the name of a leaderboard handle. Returns an empty string if the leaderboard handle is invalid.

source

pub fn get_leaderboard_entry_count(&self, leaderboard: &Leaderboard) -> i32

Returns the total number of entries in a leaderboard. Returns 0 if the leaderboard handle is invalid.

source

pub fn request_current_stats(&self)

Triggers a UserStatsReceived callback.

source

pub fn request_global_achievement_percentages<F>(&self, cb: F)
where F: FnOnce(Result<GameId, SteamError>) + 'static + Send,

Asynchronously fetch the data for the percentage of players who have received each achievement for the current game globally.

You must have called request_current_stats() and it needs to return successfully via its callback prior to calling this!*

*Note: Not sure if this is applicable, as the other achievement functions requiring request_current_stats() don’t specifically need it to be called in order for them to complete successfully. Maybe it autoruns via Client::init()/init_app() somehow?

source

pub fn store_stats(&self) -> Result<(), ()>

Send the changed stats and achievements data to the server for permanent storage.

Requires request_current_stats() to have been called and a successful UserStatsReceived callback processed.

source

pub fn reset_all_stats(&self, achievements_too: bool) -> Result<(), ()>

Resets the current users stats and, optionally achievements.

source

pub fn get_stat_i32(&self, name: &str) -> Result<i32, ()>

Gets the value of a given stat for the current user

The specified stat must exist and match the type set on the Steamworks App Admin website.

Requires request_current_stats() to have been called and a successful UserStatsReceived callback processed.

source

pub fn set_stat_i32(&self, name: &str, stat: i32) -> Result<(), ()>

Sets / updates the value of a given stat for the current user

This call only changes the value in-memory and is very cheap. To commit the stats you must call store_stats()

The specified stat must exist and match the type set on the Steamworks App Admin website.

Requires request_current_stats() to have been called and a successful UserStatsReceived callback processed.

source

pub fn get_stat_f32(&self, name: &str) -> Result<f32, ()>

Gets the value of a given stat for the current user

The specified stat must exist and match the type set on the Steamworks App Admin website.

Requires request_current_stats() to have been called and a successful UserStatsReceived callback processed.

source

pub fn set_stat_f32(&self, name: &str, stat: f32) -> Result<(), ()>

Sets / updates the value of a given stat for the current user

This call only changes the value in-memory and is very cheap. To commit the stats you must call store_stats()

The specified stat must exist and match the type set on the Steamworks App Admin website.

Requires request_current_stats() to have been called and a successful UserStatsReceived callback processed.

source

pub fn achievement(&self, name: &str) -> AchievementHelper<'_, Manager>

Access achievement API for a given achievement ‘API Name’.

Requires request_current_stats() to have been called and a successful UserStatsReceived callback processed.

source

pub fn get_num_achievements(&self) -> Result<u32, ()>

Get the number of achievements defined in the App Admin panel of the Steamworks website.

This is used for iterating through all of the achievements with GetAchievementName.

Returns 0 if the current App ID has no achievements.

Note: Returns an error for AppId 480 (Spacewar)!

source

pub fn get_achievement_names(&self) -> Option<Vec<String>>

Returns an array of all achievement names for the current AppId.

Returns an empty string for an achievement name if iAchievement is not a valid index, and the current AppId must have achievements.

Auto Trait Implementations§

§

impl<Manager> RefUnwindSafe for UserStats<Manager>
where Manager: RefUnwindSafe,

§

impl<Manager> !Send for UserStats<Manager>

§

impl<Manager> !Sync for UserStats<Manager>

§

impl<Manager> Unpin for UserStats<Manager>

§

impl<Manager> UnwindSafe for UserStats<Manager>
where Manager: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.