icrate 0.1.2

Bindings to Apple's frameworks
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use crate::common::*;
use crate::AppKit::*;
use crate::Foundation::*;
use crate::GameKit::*;

ns_enum!(
    #[underlying(NSInteger)]
    pub enum GKInviteRecipientResponse {
        GKInviteRecipientResponseAccepted = 0,
        GKInviteRecipientResponseDeclined = 1,
        GKInviteRecipientResponseFailed = 2,
        GKInviteRecipientResponseIncompatible = 3,
        GKInviteRecipientResponseUnableToConnect = 4,
        GKInviteRecipientResponseNoAnswer = 5,
        GKInviteeResponseAccepted = GKInviteRecipientResponseAccepted,
        GKInviteeResponseDeclined = GKInviteRecipientResponseDeclined,
        GKInviteeResponseFailed = GKInviteRecipientResponseFailed,
        GKInviteeResponseIncompatible = GKInviteRecipientResponseIncompatible,
        GKInviteeResponseUnableToConnect = GKInviteRecipientResponseUnableToConnect,
        GKInviteeResponseNoAnswer = GKInviteRecipientResponseNoAnswer,
    }
);

pub type GKInviteeResponse = GKInviteRecipientResponse;

ns_enum!(
    #[underlying(NSUInteger)]
    pub enum GKMatchType {
        GKMatchTypePeerToPeer = 0,
        GKMatchTypeHosted = 1,
        GKMatchTypeTurnBased = 2,
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "GameKit_GKMatchRequest")]
    pub struct GKMatchRequest;

    #[cfg(feature = "GameKit_GKMatchRequest")]
    unsafe impl ClassType for GKMatchRequest {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "GameKit_GKMatchRequest")]
unsafe impl NSObjectProtocol for GKMatchRequest {}

extern_methods!(
    #[cfg(feature = "GameKit_GKMatchRequest")]
    unsafe impl GKMatchRequest {
        #[method(minPlayers)]
        pub unsafe fn minPlayers(&self) -> NSUInteger;

        #[method(setMinPlayers:)]
        pub unsafe fn setMinPlayers(&self, min_players: NSUInteger);

        #[method(maxPlayers)]
        pub unsafe fn maxPlayers(&self) -> NSUInteger;

        #[method(setMaxPlayers:)]
        pub unsafe fn setMaxPlayers(&self, max_players: NSUInteger);

        #[method(playerGroup)]
        pub unsafe fn playerGroup(&self) -> NSUInteger;

        #[method(setPlayerGroup:)]
        pub unsafe fn setPlayerGroup(&self, player_group: NSUInteger);

        #[method(playerAttributes)]
        pub unsafe fn playerAttributes(&self) -> u32;

        #[method(setPlayerAttributes:)]
        pub unsafe fn setPlayerAttributes(&self, player_attributes: u32);

        #[cfg(all(feature = "Foundation_NSArray", feature = "GameKit_GKPlayer"))]
        #[method_id(@__retain_semantics Other recipients)]
        pub unsafe fn recipients(&self) -> Option<Id<NSArray<GKPlayer>>>;

        #[cfg(all(feature = "Foundation_NSArray", feature = "GameKit_GKPlayer"))]
        #[method(setRecipients:)]
        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>);

        #[cfg(feature = "Foundation_NSString")]
        #[method_id(@__retain_semantics Other inviteMessage)]
        pub unsafe fn inviteMessage(&self) -> Option<Id<NSString>>;

        #[cfg(feature = "Foundation_NSString")]
        #[method(setInviteMessage:)]
        pub unsafe fn setInviteMessage(&self, invite_message: Option<&NSString>);

        #[method(defaultNumberOfPlayers)]
        pub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger;

        #[method(setDefaultNumberOfPlayers:)]
        pub unsafe fn setDefaultNumberOfPlayers(&self, default_number_of_players: NSUInteger);

        #[deprecated]
        #[method(restrictToAutomatch)]
        pub unsafe fn restrictToAutomatch(&self) -> bool;

        #[deprecated]
        #[method(setRestrictToAutomatch:)]
        pub unsafe fn setRestrictToAutomatch(&self, restrict_to_automatch: bool);

        #[cfg(feature = "GameKit_GKPlayer")]
        #[method(recipientResponseHandler)]
        pub unsafe fn recipientResponseHandler(
            &self,
        ) -> *mut Block<(NonNull<GKPlayer>, GKInviteRecipientResponse), ()>;

        #[cfg(feature = "GameKit_GKPlayer")]
        #[method(setRecipientResponseHandler:)]
        pub unsafe fn setRecipientResponseHandler(
            &self,
            recipient_response_handler: Option<
                &Block<(NonNull<GKPlayer>, GKInviteRecipientResponse), ()>,
            >,
        );

        #[cfg(feature = "Foundation_NSString")]
        #[deprecated]
        #[method(inviteeResponseHandler)]
        pub unsafe fn inviteeResponseHandler(
            &self,
        ) -> *mut Block<(NonNull<NSString>, GKInviteeResponse), ()>;

        #[cfg(feature = "Foundation_NSString")]
        #[deprecated]
        #[method(setInviteeResponseHandler:)]
        pub unsafe fn setInviteeResponseHandler(
            &self,
            invitee_response_handler: Option<&Block<(NonNull<NSString>, GKInviteeResponse), ()>>,
        );

        #[method(maxPlayersAllowedForMatchOfType:)]
        pub unsafe fn maxPlayersAllowedForMatchOfType(match_type: GKMatchType) -> NSUInteger;

        #[cfg(all(feature = "Foundation_NSArray", feature = "Foundation_NSString"))]
        #[deprecated]
        #[method_id(@__retain_semantics Other playersToInvite)]
        pub unsafe fn playersToInvite(&self) -> Option<Id<NSArray<NSString>>>;

        #[cfg(all(feature = "Foundation_NSArray", feature = "Foundation_NSString"))]
        #[deprecated]
        #[method(setPlayersToInvite:)]
        pub unsafe fn setPlayersToInvite(&self, players_to_invite: Option<&NSArray<NSString>>);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "GameKit_GKMatchRequest")]
    unsafe impl GKMatchRequest {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "GameKit_GKInvite")]
    pub struct GKInvite;

    #[cfg(feature = "GameKit_GKInvite")]
    unsafe impl ClassType for GKInvite {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "GameKit_GKInvite")]
unsafe impl NSObjectProtocol for GKInvite {}

extern_methods!(
    #[cfg(feature = "GameKit_GKInvite")]
    unsafe impl GKInvite {
        #[cfg(feature = "GameKit_GKPlayer")]
        #[method_id(@__retain_semantics Other sender)]
        pub unsafe fn sender(&self) -> Id<GKPlayer>;

        #[method(isHosted)]
        pub unsafe fn isHosted(&self) -> bool;

        #[method(playerGroup)]
        pub unsafe fn playerGroup(&self) -> NSUInteger;

        #[method(playerAttributes)]
        pub unsafe fn playerAttributes(&self) -> u32;

        #[cfg(feature = "Foundation_NSString")]
        #[deprecated]
        #[method_id(@__retain_semantics Other inviter)]
        pub unsafe fn inviter(&self) -> Id<NSString>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "GameKit_GKInvite")]
    unsafe impl GKInvite {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_protocol!(
    pub unsafe trait GKInviteEventListener {
        #[cfg(all(feature = "GameKit_GKInvite", feature = "GameKit_GKPlayer"))]
        #[optional]
        #[method(player:didAcceptInvite:)]
        unsafe fn player_didAcceptInvite(&self, player: &GKPlayer, invite: &GKInvite);

        #[cfg(all(feature = "Foundation_NSArray", feature = "GameKit_GKPlayer"))]
        #[optional]
        #[method(player:didRequestMatchWithRecipients:)]
        unsafe fn player_didRequestMatchWithRecipients(
            &self,
            player: &GKPlayer,
            recipient_players: &NSArray<GKPlayer>,
        );

        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSString",
            feature = "GameKit_GKPlayer"
        ))]
        #[deprecated]
        #[optional]
        #[method(player:didRequestMatchWithPlayers:)]
        unsafe fn player_didRequestMatchWithPlayers(
            &self,
            player: &GKPlayer,
            player_i_ds_to_invite: &NSArray<NSString>,
        );
    }

    unsafe impl ProtocolType for dyn GKInviteEventListener {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "GameKit_GKMatchmaker")]
    pub struct GKMatchmaker;

    #[cfg(feature = "GameKit_GKMatchmaker")]
    unsafe impl ClassType for GKMatchmaker {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "GameKit_GKMatchmaker")]
unsafe impl NSObjectProtocol for GKMatchmaker {}

extern_methods!(
    #[cfg(feature = "GameKit_GKMatchmaker")]
    unsafe impl GKMatchmaker {
        #[method_id(@__retain_semantics Other sharedMatchmaker)]
        pub unsafe fn sharedMatchmaker() -> Id<GKMatchmaker>;

        #[cfg(all(
            feature = "Foundation_NSError",
            feature = "GameKit_GKInvite",
            feature = "GameKit_GKMatch"
        ))]
        #[method(matchForInvite:completionHandler:)]
        pub unsafe fn matchForInvite_completionHandler(
            &self,
            invite: &GKInvite,
            completion_handler: Option<&Block<(*mut GKMatch, *mut NSError), ()>>,
        );

        #[cfg(all(
            feature = "Foundation_NSError",
            feature = "GameKit_GKMatch",
            feature = "GameKit_GKMatchRequest"
        ))]
        #[method(findMatchForRequest:withCompletionHandler:)]
        pub unsafe fn findMatchForRequest_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: Option<&Block<(*mut GKMatch, *mut NSError), ()>>,
        );

        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError",
            feature = "GameKit_GKMatchRequest",
            feature = "GameKit_GKPlayer"
        ))]
        #[method(findPlayersForHostedRequest:withCompletionHandler:)]
        pub unsafe fn findPlayersForHostedRequest_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: Option<&Block<(*mut NSArray<GKPlayer>, *mut NSError), ()>>,
        );

        #[cfg(all(
            feature = "Foundation_NSError",
            feature = "GameKit_GKMatch",
            feature = "GameKit_GKMatchRequest"
        ))]
        #[method(addPlayersToMatch:matchRequest:completionHandler:)]
        pub unsafe fn addPlayersToMatch_matchRequest_completionHandler(
            &self,
            r#match: &GKMatch,
            match_request: &GKMatchRequest,
            completion_handler: Option<&Block<(*mut NSError,), ()>>,
        );

        #[method(cancel)]
        pub unsafe fn cancel(&self);

        #[cfg(feature = "GameKit_GKPlayer")]
        #[method(cancelPendingInviteToPlayer:)]
        pub unsafe fn cancelPendingInviteToPlayer(&self, player: &GKPlayer);

        #[cfg(feature = "GameKit_GKMatch")]
        #[method(finishMatchmakingForMatch:)]
        pub unsafe fn finishMatchmakingForMatch(&self, r#match: &GKMatch);

        #[cfg(feature = "Foundation_NSError")]
        #[method(queryPlayerGroupActivity:withCompletionHandler:)]
        pub unsafe fn queryPlayerGroupActivity_withCompletionHandler(
            &self,
            player_group: NSUInteger,
            completion_handler: Option<&Block<(NSInteger, *mut NSError), ()>>,
        );

        #[cfg(feature = "Foundation_NSError")]
        #[method(queryActivityWithCompletionHandler:)]
        pub unsafe fn queryActivityWithCompletionHandler(
            &self,
            completion_handler: Option<&Block<(NSInteger, *mut NSError), ()>>,
        );

        #[cfg(feature = "GameKit_GKPlayer")]
        #[method(startBrowsingForNearbyPlayersWithHandler:)]
        pub unsafe fn startBrowsingForNearbyPlayersWithHandler(
            &self,
            reachable_handler: Option<&Block<(NonNull<GKPlayer>, Bool), ()>>,
        );

        #[method(stopBrowsingForNearbyPlayers)]
        pub unsafe fn stopBrowsingForNearbyPlayers(&self);

        #[cfg(feature = "GameKit_GKPlayer")]
        #[method(startGroupActivityWithPlayerHandler:)]
        pub unsafe fn startGroupActivityWithPlayerHandler(
            &self,
            handler: &Block<(NonNull<GKPlayer>,), ()>,
        );

        #[method(stopGroupActivity)]
        pub unsafe fn stopGroupActivity(&self);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "GameKit_GKMatchmaker")]
    unsafe impl GKMatchmaker {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_methods!(
    /// GKDeprecated
    #[cfg(feature = "GameKit_GKMatchmaker")]
    unsafe impl GKMatchmaker {
        #[cfg(all(feature = "Foundation_NSArray", feature = "GameKit_GKInvite"))]
        #[deprecated = "Use registerListener on GKLocalPlayer to register an object that implements the GKInviteEventListenerProtocol instead."]
        #[method(inviteHandler)]
        pub unsafe fn inviteHandler(&self) -> *mut Block<(NonNull<GKInvite>, *mut NSArray), ()>;

        #[cfg(all(feature = "Foundation_NSArray", feature = "GameKit_GKInvite"))]
        #[deprecated = "Use registerListener on GKLocalPlayer to register an object that implements the GKInviteEventListenerProtocol instead."]
        #[method(setInviteHandler:)]
        pub unsafe fn setInviteHandler(
            &self,
            invite_handler: Option<&Block<(NonNull<GKInvite>, *mut NSArray), ()>>,
        );
    }
);

extern_methods!(
    /// Obsoleted
    #[cfg(feature = "GameKit_GKMatchmaker")]
    unsafe impl GKMatchmaker {
        #[cfg(feature = "Foundation_NSString")]
        #[deprecated]
        #[method(startBrowsingForNearbyPlayersWithReachableHandler:)]
        pub unsafe fn startBrowsingForNearbyPlayersWithReachableHandler(
            &self,
            reachable_handler: Option<&Block<(NonNull<NSString>, Bool), ()>>,
        );

        #[cfg(feature = "Foundation_NSString")]
        #[deprecated]
        #[method(cancelInviteToPlayer:)]
        pub unsafe fn cancelInviteToPlayer(&self, player_id: &NSString);

        #[cfg(all(
            feature = "Foundation_NSArray",
            feature = "Foundation_NSError",
            feature = "Foundation_NSString",
            feature = "GameKit_GKMatchRequest"
        ))]
        #[deprecated]
        #[method(findPlayersForHostedMatchRequest:withCompletionHandler:)]
        pub unsafe fn findPlayersForHostedMatchRequest_withCompletionHandler(
            &self,
            request: &GKMatchRequest,
            completion_handler: Option<&Block<(*mut NSArray<NSString>, *mut NSError), ()>>,
        );
    }
);