objc2_game_kit/generated/
GKLocalPlayer.rs1use 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_class!(
14 #[unsafe(super(GKPlayer, GKBasePlayer, NSObject))]
16 #[derive(Debug, PartialEq, Eq, Hash)]
17 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
18 pub struct GKLocalPlayer;
19);
20
21#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
22extern_conformance!(
23 unsafe impl NSCopying for GKLocalPlayer {}
24);
25
26#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
27unsafe impl CopyingHelper for GKLocalPlayer {
28 type Result = Self;
29}
30
31#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
32extern_conformance!(
33 unsafe impl NSObjectProtocol for GKLocalPlayer {}
34);
35
36#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
37impl GKLocalPlayer {
38 extern_methods!(
39 #[unsafe(method(local))]
43 #[unsafe(method_family = none)]
44 pub unsafe fn local() -> Retained<GKLocalPlayer>;
45
46 #[unsafe(method(localPlayer))]
47 #[unsafe(method_family = none)]
48 pub unsafe fn localPlayer() -> Retained<GKLocalPlayer>;
49
50 #[unsafe(method(isAuthenticated))]
52 #[unsafe(method_family = none)]
53 pub unsafe fn isAuthenticated(&self) -> bool;
54
55 #[unsafe(method(isUnderage))]
57 #[unsafe(method_family = none)]
58 pub unsafe fn isUnderage(&self) -> bool;
59
60 #[unsafe(method(isMultiplayerGamingRestricted))]
62 #[unsafe(method_family = none)]
63 pub unsafe fn isMultiplayerGamingRestricted(&self) -> bool;
64
65 #[unsafe(method(isPersonalizedCommunicationRestricted))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn isPersonalizedCommunicationRestricted(&self) -> bool;
69
70 #[cfg(feature = "block2")]
71 #[unsafe(method(loadRecentPlayersWithCompletionHandler:))]
76 #[unsafe(method_family = none)]
77 pub unsafe fn loadRecentPlayersWithCompletionHandler(
78 &self,
79 completion_handler: Option<
80 &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
81 >,
82 );
83
84 #[cfg(feature = "block2")]
85 #[unsafe(method(loadChallengableFriendsWithCompletionHandler:))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn loadChallengableFriendsWithCompletionHandler(
92 &self,
93 completion_handler: Option<
94 &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
95 >,
96 );
97
98 #[cfg(feature = "block2")]
99 #[unsafe(method(setDefaultLeaderboardIdentifier:completionHandler:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn setDefaultLeaderboardIdentifier_completionHandler(
107 &self,
108 leaderboard_identifier: &NSString,
109 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
110 );
111
112 #[cfg(feature = "block2")]
113 #[unsafe(method(loadDefaultLeaderboardIdentifierWithCompletionHandler:))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn loadDefaultLeaderboardIdentifierWithCompletionHandler(
121 &self,
122 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSString, *mut NSError)>>,
123 );
124
125 #[cfg(feature = "block2")]
126 #[unsafe(method(fetchItemsForIdentityVerificationSignature:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn fetchItemsForIdentityVerificationSignature(
133 &self,
134 completion_handler: Option<
135 &block2::DynBlock<dyn Fn(*mut NSURL, *mut NSData, *mut NSData, u64, *mut NSError)>,
136 >,
137 );
138 );
139}
140
141#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
143impl GKLocalPlayer {
144 extern_methods!(
145 #[unsafe(method(anonymousGuestPlayerWithIdentifier:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn anonymousGuestPlayerWithIdentifier(
148 guest_identifier: &NSString,
149 ) -> Retained<Self>;
150 );
151}
152
153#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
155impl GKLocalPlayer {
156 extern_methods!(
157 #[unsafe(method(init))]
158 #[unsafe(method_family = init)]
159 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
160
161 #[unsafe(method(new))]
162 #[unsafe(method_family = new)]
163 pub unsafe fn new() -> Retained<Self>;
164 );
165}
166
167extern_protocol!(
168 #[cfg(all(
170 feature = "GKEventListener",
171 feature = "GKGameActivityListener",
172 feature = "GKMatchmaker",
173 feature = "GKSavedGameListener",
174 feature = "GKTurnBasedMatch"
175 ))]
176 pub unsafe trait GKLocalPlayerListener:
177 GKChallengeListener
178 + GKGameActivityListener
179 + GKInviteEventListener
180 + GKTurnBasedEventListener
181 + GKSavedGameListener
182 {
183 }
184);
185
186#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
188impl GKLocalPlayer {
189 extern_methods!(
190 #[cfg(all(
191 feature = "GKEventListener",
192 feature = "GKGameActivityListener",
193 feature = "GKMatchmaker",
194 feature = "GKSavedGameListener",
195 feature = "GKTurnBasedMatch"
196 ))]
197 #[unsafe(method(registerListener:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn registerListener(&self, listener: &ProtocolObject<dyn GKLocalPlayerListener>);
201
202 #[cfg(all(
203 feature = "GKEventListener",
204 feature = "GKGameActivityListener",
205 feature = "GKMatchmaker",
206 feature = "GKSavedGameListener",
207 feature = "GKTurnBasedMatch"
208 ))]
209 #[unsafe(method(unregisterListener:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn unregisterListener(
212 &self,
213 listener: &ProtocolObject<dyn GKLocalPlayerListener>,
214 );
215
216 #[unsafe(method(unregisterAllListeners))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn unregisterAllListeners(&self);
219 );
220}
221
222extern "C" {
223 pub static GKPlayerAuthenticationDidChangeNotificationName: &'static NSNotificationName;
227}
228
229#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
231impl GKLocalPlayer {
232 extern_methods!(
233 #[cfg(feature = "block2")]
234 #[deprecated]
235 #[unsafe(method(setDefaultLeaderboardCategoryID:completionHandler:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn setDefaultLeaderboardCategoryID_completionHandler(
238 &self,
239 category_id: Option<&NSString>,
240 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
241 );
242
243 #[cfg(feature = "block2")]
244 #[deprecated]
245 #[unsafe(method(loadDefaultLeaderboardCategoryIDWithCompletionHandler:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn loadDefaultLeaderboardCategoryIDWithCompletionHandler(
248 &self,
249 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSString, *mut NSError)>>,
250 );
251
252 #[cfg(feature = "block2")]
253 #[deprecated]
254 #[unsafe(method(authenticateWithCompletionHandler:))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn authenticateWithCompletionHandler(
257 &self,
258 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
259 );
260
261 #[cfg(feature = "block2")]
262 #[deprecated]
263 #[unsafe(method(loadFriendPlayersWithCompletionHandler:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn loadFriendPlayersWithCompletionHandler(
266 &self,
267 completion_handler: Option<
268 &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
269 >,
270 );
271
272 #[cfg(feature = "block2")]
273 #[deprecated]
278 #[unsafe(method(generateIdentityVerificationSignatureWithCompletionHandler:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn generateIdentityVerificationSignatureWithCompletionHandler(
281 &self,
282 completion_handler: Option<
283 &block2::DynBlock<dyn Fn(*mut NSURL, *mut NSData, *mut NSData, u64, *mut NSError)>,
284 >,
285 );
286 );
287}
288
289#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
291impl GKLocalPlayer {
292 extern_methods!(
293 #[cfg(feature = "block2")]
294 #[deprecated]
296 #[unsafe(method(loadFriendsWithCompletionHandler:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn loadFriendsWithCompletionHandler(
299 &self,
300 completion_handler: Option<
301 &block2::DynBlock<dyn Fn(*mut NSArray<NSString>, *mut NSError)>,
302 >,
303 );
304
305 #[deprecated]
307 #[unsafe(method(friends))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn friends(&self) -> Option<Retained<NSArray<NSString>>>;
310 );
311}
312
313#[repr(transparent)]
316#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
317pub struct GKFriendsAuthorizationStatus(pub NSInteger);
318impl GKFriendsAuthorizationStatus {
319 #[doc(alias = "GKFriendsAuthorizationStatusNotDetermined")]
320 pub const NotDetermined: Self = Self(0);
321 #[doc(alias = "GKFriendsAuthorizationStatusRestricted")]
322 pub const Restricted: Self = Self(1);
323 #[doc(alias = "GKFriendsAuthorizationStatusDenied")]
324 pub const Denied: Self = Self(2);
325 #[doc(alias = "GKFriendsAuthorizationStatusAuthorized")]
326 pub const Authorized: Self = Self(3);
327}
328
329unsafe impl Encode for GKFriendsAuthorizationStatus {
330 const ENCODING: Encoding = NSInteger::ENCODING;
331}
332
333unsafe impl RefEncode for GKFriendsAuthorizationStatus {
334 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
335}
336
337#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
339impl GKLocalPlayer {
340 extern_methods!(
341 #[cfg(feature = "block2")]
342 #[unsafe(method(loadFriendsAuthorizationStatus:))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn loadFriendsAuthorizationStatus(
345 &self,
346 completion_handler: &block2::DynBlock<
347 dyn Fn(GKFriendsAuthorizationStatus, *mut NSError),
348 >,
349 );
350
351 #[cfg(feature = "block2")]
352 #[unsafe(method(loadFriends:))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn loadFriends(
355 &self,
356 completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
357 );
358
359 #[cfg(feature = "block2")]
360 #[unsafe(method(loadFriendsWithIdentifiers:completionHandler:))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn loadFriendsWithIdentifiers_completionHandler(
363 &self,
364 identifiers: &NSArray<NSString>,
365 completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
366 );
367 );
368}
369
370#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
372impl GKLocalPlayer {
373 extern_methods!(
374 #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
375 #[cfg(target_os = "macos")]
376 #[unsafe(method(authenticateHandler))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn authenticateHandler(
383 &self,
384 mtm: MainThreadMarker,
385 ) -> *mut block2::DynBlock<dyn Fn(*mut NSViewController, *mut NSError)>;
386
387 #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
388 #[cfg(target_os = "macos")]
389 #[unsafe(method(setAuthenticateHandler:))]
393 #[unsafe(method_family = none)]
394 pub unsafe fn setAuthenticateHandler(
395 &self,
396 authenticate_handler: Option<
397 &block2::DynBlock<dyn Fn(*mut NSViewController, *mut NSError)>,
398 >,
399 );
400
401 #[unsafe(method(isPresentingFriendRequestViewController))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn isPresentingFriendRequestViewController(&self) -> bool;
405
406 #[cfg(feature = "objc2-app-kit")]
407 #[cfg(target_os = "macos")]
408 #[unsafe(method(presentFriendRequestCreatorFromViewController:error:_))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn presentFriendRequestCreatorFromViewController_error(
420 &self,
421 view_controller: &NSViewController,
422 ) -> Result<(), Retained<NSError>>;
423
424 #[cfg(feature = "objc2-app-kit")]
425 #[cfg(target_os = "macos")]
426 #[unsafe(method(presentFriendRequestCreatorFromWindow:error:_))]
436 #[unsafe(method_family = none)]
437 pub unsafe fn presentFriendRequestCreatorFromWindow_error(
438 &self,
439 window: Option<&NSWindow>,
440 ) -> Result<(), Retained<NSError>>;
441 );
442}