objc2_game_kit/generated/
GKPlayer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern "C" {
14    /// Deprecated methods that previously returned player IDs will return GKPlayerIDNoLongerAvailable instead.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkplayeridnolongeravailable?language=objc)
17    pub static GKPlayerIDNoLongerAvailable: &'static NSString;
18}
19
20extern_class!(
21    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkplayer?language=objc)
22    #[unsafe(super(GKBasePlayer, NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    #[cfg(feature = "GKBasePlayer")]
25    pub struct GKPlayer;
26);
27
28#[cfg(feature = "GKBasePlayer")]
29extern_conformance!(
30    unsafe impl NSCopying for GKPlayer {}
31);
32
33#[cfg(feature = "GKBasePlayer")]
34unsafe impl CopyingHelper for GKPlayer {
35    type Result = Self;
36}
37
38#[cfg(feature = "GKBasePlayer")]
39extern_conformance!(
40    unsafe impl NSObjectProtocol for GKPlayer {}
41);
42
43#[cfg(feature = "GKBasePlayer")]
44impl GKPlayer {
45    extern_methods!(
46        /// This convenience method checks if the gamePlayerID and the teamPlayerID (scopedIDs) are persistent or unique for the instantiation of this app.
47        #[unsafe(method(scopedIDsArePersistent))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn scopedIDsArePersistent(&self) -> bool;
50
51        /// This is the player's unique and persistent ID that is scoped to this application.
52        #[unsafe(method(gamePlayerID))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn gamePlayerID(&self) -> Retained<NSString>;
55
56        /// This is the player's unique and persistent ID that is scoped to the Apple Store Connect Team identifier of this application.
57        #[unsafe(method(teamPlayerID))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn teamPlayerID(&self) -> Retained<NSString>;
60
61        /// This is player's alias to be displayed. The display name may be very long, so be sure to use appropriate string truncation API when drawing.
62        #[unsafe(method(displayName))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn displayName(&self) -> Retained<NSString>;
65
66        /// The alias property contains the player's nickname. When you need to display the name to the user, consider using displayName instead. The nickname is unique but not invariant: the player may change their nickname. The nickname may be very long, so be sure to use appropriate string truncation API when drawing.
67        #[unsafe(method(alias))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn alias(&self) -> Retained<NSString>;
70
71        #[unsafe(method(anonymousGuestPlayerWithIdentifier:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn anonymousGuestPlayerWithIdentifier(
74            guest_identifier: &NSString,
75        ) -> Retained<Self>;
76
77        #[unsafe(method(guestIdentifier))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn guestIdentifier(&self) -> Option<Retained<NSString>>;
80
81        #[unsafe(method(isInvitable))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn isInvitable(&self) -> bool;
84    );
85}
86
87/// Methods declared on superclass `NSObject`.
88#[cfg(feature = "GKBasePlayer")]
89impl GKPlayer {
90    extern_methods!(
91        #[unsafe(method(init))]
92        #[unsafe(method_family = init)]
93        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
94
95        #[unsafe(method(new))]
96        #[unsafe(method_family = new)]
97        pub unsafe fn new() -> Retained<Self>;
98    );
99}
100
101/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkphotosize?language=objc)
102// NS_ENUM
103#[repr(transparent)]
104#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
105pub struct GKPhotoSize(pub NSInteger);
106impl GKPhotoSize {
107    #[doc(alias = "GKPhotoSizeSmall")]
108    pub const Small: Self = Self(0);
109    #[doc(alias = "GKPhotoSizeNormal")]
110    pub const Normal: Self = Self(1);
111}
112
113unsafe impl Encode for GKPhotoSize {
114    const ENCODING: Encoding = NSInteger::ENCODING;
115}
116
117unsafe impl RefEncode for GKPhotoSize {
118    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
119}
120
121/// UI.
122#[cfg(feature = "GKBasePlayer")]
123impl GKPlayer {
124    extern_methods!(
125        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
126        #[cfg(target_os = "macos")]
127        /// Asynchronously load the player's photo. Error will be nil on success.
128        /// Possible reasons for error:
129        /// 1. Communications failure
130        #[unsafe(method(loadPhotoForSize:withCompletionHandler:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn loadPhotoForSize_withCompletionHandler(
133            &self,
134            size: GKPhotoSize,
135            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>>,
136        );
137    );
138}
139
140extern "C" {
141    /// Notification will be posted whenever the player details changes. The object of the notification will be the player.
142    ///
143    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkplayerdidchangenotificationname?language=objc)
144    pub static GKPlayerDidChangeNotificationName: &'static NSNotificationName;
145}
146
147/// Deprecated.
148#[cfg(feature = "GKBasePlayer")]
149impl GKPlayer {
150    extern_methods!(
151        #[deprecated]
152        #[unsafe(method(isFriend))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn isFriend(&self) -> bool;
155
156        #[deprecated = "Use ``GKPlayer/gamePlayerID`` or ``GKPlayer/teamPlayerID`` instead."]
157        #[unsafe(method(playerID))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn playerID(&self) -> Retained<NSString>;
160
161        #[cfg(feature = "block2")]
162        /// Load the Game Center players for the playerIDs provided. Error will be nil on success.
163        /// Possible reasons for error:
164        /// 1. Unauthenticated local player
165        /// 2. Communications failure
166        /// 3. Invalid player identifier
167        #[deprecated]
168        #[unsafe(method(loadPlayersForIdentifiers:withCompletionHandler:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn loadPlayersForIdentifiers_withCompletionHandler(
171            identifiers: &NSArray<NSString>,
172            completion_handler: Option<
173                &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
174            >,
175        );
176    );
177}