aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Collins <[email protected]>2018-02-27 12:18:56 +0000
committerMatthew Collins <[email protected]>2018-02-27 12:18:56 +0000
commitdb7c3f7bcd5f1e804345bf90591f3e360ef456fb (patch)
tree621b19bddf5078ef8c5d763575eeb6745888cb64 /src
parentDerive `Ord`/`Eq` for SteamId (diff)
downloadsteamworks-rs-db7c3f7bcd5f1e804345bf90591f3e360ef456fb.tar.xz
steamworks-rs-db7c3f7bcd5f1e804345bf90591f3e360ef456fb.zip
Add basic steam user accessor
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs15
-rw-r--r--src/user.rs17
2 files changed, 32 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 5753db1..df42732 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -18,6 +18,8 @@ mod friends;
pub use friends::*;
mod matchmaking;
pub use matchmaking::*;
+mod user;
+pub use user::*;
use std::sync::{Arc, Mutex, Weak};
use std::ffi::{CString, CStr};
@@ -242,6 +244,19 @@ impl Client {
}
}
+
+ /// Returns an accessor to the steam user interface
+ pub fn user(&self) -> User {
+ unsafe {
+ let user = sys::steam_rust_get_user();
+ debug_assert!(!user.is_null());
+ User {
+ user,
+ _client: self.inner.clone(),
+ }
+ }
+
+ }
}
impl Drop for ClientInner {
diff --git a/src/user.rs b/src/user.rs
new file mode 100644
index 0000000..fcd3e40
--- /dev/null
+++ b/src/user.rs
@@ -0,0 +1,17 @@
+
+use super::*;
+
+/// Access to the steam user interface
+pub struct User {
+ pub(crate) user: *mut sys::ISteamUser,
+ pub(crate) _client: Arc<ClientInner>,
+}
+
+impl User {
+ /// Returns the steam id of the current user
+ pub fn steam_id(&self) -> SteamId {
+ unsafe {
+ SteamId(sys::SteamAPI_ISteamUser_GetSteamID(self.user))
+ }
+ }
+} \ No newline at end of file