aboutsummaryrefslogtreecommitdiff
path: root/src/friends.rs
diff options
context:
space:
mode:
authorMatthew Collins <[email protected]>2018-02-27 20:30:40 +0000
committerMatthew Collins <[email protected]>2018-02-27 20:30:40 +0000
commite99c0e0adc490b94b037838757bfa6647f3c3568 (patch)
tree1ab022877d951a111820b5c0a1d35facac3ef6ee /src/friends.rs
parentAdd accessors for `SteamId`'s inner values (diff)
downloadsteamworks-rs-e99c0e0adc490b94b037838757bfa6647f3c3568.tar.xz
steamworks-rs-e99c0e0adc490b94b037838757bfa6647f3c3568.zip
Try and make the accessors generic over the client and server
Diffstat (limited to 'src/friends.rs')
-rw-r--r--src/friends.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/friends.rs b/src/friends.rs
index 5885e6f..c57d54d 100644
--- a/src/friends.rs
+++ b/src/friends.rs
@@ -41,13 +41,15 @@ bitflags! {
const STEAM_LEVEL = 0x2000;
}
}
-pub struct Friends {
+
+/// Access to the steam friends interface
+pub struct Friends<Manager> {
pub(crate) friends: *mut sys::ISteamFriends,
- pub(crate) _client: Arc<ClientInner>,
+ pub(crate) inner: Arc<Inner<Manager>>,
}
-impl Friends {
- pub fn get_friends(&self, flags: FriendFlags) -> Vec<Friend> {
+impl <Manager> Friends<Manager> {
+ pub fn get_friends(&self, flags: FriendFlags) -> Vec<Friend<Manager>> {
unsafe {
let count = sys::SteamAPI_ISteamFriends_GetFriendCount(self.friends, flags.bits() as _);
let mut friends = Vec::with_capacity(count as usize);
@@ -56,7 +58,7 @@ impl Friends {
friends.push(Friend {
id: friend,
friends: self.friends,
- _client: self._client.clone(),
+ _inner: self.inner.clone(),
});
}
@@ -102,19 +104,19 @@ unsafe impl Callback for PersonaStateChange {
}
}
-pub struct Friend {
+pub struct Friend<Manager> {
id: SteamId,
friends: *mut sys::ISteamFriends,
- _client: Arc<ClientInner>,
+ _inner: Arc<Inner<Manager>>,
}
-impl Debug for Friend {
+impl <Manager> Debug for Friend<Manager> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "Friend({:?})", self.id)
}
}
-impl Friend {
+impl <Manager> Friend<Manager> {
pub fn id(&self) -> SteamId {
self.id
}