#[repr(C)]pub struct GKMatchRequest { /* private fields */ }
GKMatchmaker
only.Expand description
GKMatchRequest represents the parameters needed to create the match.
See also Apple’s documentation
Implementations§
Source§impl GKMatchRequest
impl GKMatchRequest
Sourcepub unsafe fn minPlayers(&self) -> NSUInteger
pub unsafe fn minPlayers(&self) -> NSUInteger
Minimum number of players for the match
Sourcepub unsafe fn setMinPlayers(&self, min_players: NSUInteger)
pub unsafe fn setMinPlayers(&self, min_players: NSUInteger)
Setter for minPlayers
.
Sourcepub unsafe fn maxPlayers(&self) -> NSUInteger
pub unsafe fn maxPlayers(&self) -> NSUInteger
Maximum number of players for the match
Sourcepub unsafe fn setMaxPlayers(&self, max_players: NSUInteger)
pub unsafe fn setMaxPlayers(&self, max_players: NSUInteger)
Setter for maxPlayers
.
Sourcepub unsafe fn playerGroup(&self) -> NSUInteger
pub unsafe fn playerGroup(&self) -> NSUInteger
The player group identifier. Matchmaking will only take place between players in the same group.
Sourcepub unsafe fn setPlayerGroup(&self, player_group: NSUInteger)
pub unsafe fn setPlayerGroup(&self, player_group: NSUInteger)
Setter for playerGroup
.
Sourcepub unsafe fn playerAttributes(&self) -> u32
pub unsafe fn playerAttributes(&self) -> u32
optional mask that specifies the role that the local player would like to play in the game. If this value is 0, it will be set to 0xFFFFFFFF (the default), and this property will be ignored. If the value is nonzero, then automatching uses the value as a mask that restricts the role the player can play in the group. Automatching with player attributes matches new players into the game so that the bitwise OR of the masks of all the players in the resulting match equals 0xFFFFFFFF.
Sourcepub unsafe fn setPlayerAttributes(&self, player_attributes: u32)
pub unsafe fn setPlayerAttributes(&self, player_attributes: u32)
Setter for playerAttributes
.
Sourcepub unsafe fn recipients(&self) -> Option<Retained<NSArray<GKPlayer>>>
Available on crate features GKBasePlayer
and GKPlayer
only.
pub unsafe fn recipients(&self) -> Option<Retained<NSArray<GKPlayer>>>
GKBasePlayer
and GKPlayer
only.Array of GKPlayers to invite, or nil if none. This array can also include local guest players.
Sourcepub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>)
Available on crate features GKBasePlayer
and GKPlayer
only.
pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>)
GKBasePlayer
and GKPlayer
only.Setter for recipients
.
Sourcepub unsafe fn inviteMessage(&self) -> Option<Retained<NSString>>
pub unsafe fn inviteMessage(&self) -> Option<Retained<NSString>>
Message sent to invited players, may be modified if using GKMatchmakerViewController Will return nil if the player is underage or restricted.
Sourcepub unsafe fn setInviteMessage(&self, invite_message: Option<&NSString>)
pub unsafe fn setInviteMessage(&self, invite_message: Option<&NSString>)
Setter for inviteMessage
.
Sourcepub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger
pub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger
Default number of players to use during matchmaking. If not set we will default to the number that the player previously set for this game, or maxPlayers.
Sourcepub unsafe fn setDefaultNumberOfPlayers(
&self,
default_number_of_players: NSUInteger,
)
pub unsafe fn setDefaultNumberOfPlayers( &self, default_number_of_players: NSUInteger, )
Setter for defaultNumberOfPlayers
.
Sourcepub unsafe fn restrictToAutomatch(&self) -> bool
👎Deprecated
pub unsafe fn restrictToAutomatch(&self) -> bool
Whether or not a match will be created only using automatch. If YES, then a player will not be able to invite anyone (including contacts, friends, and nearby players) to the match, but rely on automatching to find players for the match. Default is NO.
Sourcepub unsafe fn setRestrictToAutomatch(&self, restrict_to_automatch: bool)
👎Deprecated
pub unsafe fn setRestrictToAutomatch(&self, restrict_to_automatch: bool)
Setter for restrictToAutomatch
.
Sourcepub unsafe fn recipientResponseHandler(
&self,
) -> *mut DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>
Available on crate features GKBasePlayer
and GKPlayer
and block2
only.
pub unsafe fn recipientResponseHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>
GKBasePlayer
and GKPlayer
and block2
only.An recipientResponseHandler can be set in order to receive responses from programmatically invited players.
Sourcepub unsafe fn setRecipientResponseHandler(
&self,
recipient_response_handler: Option<&DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>>,
)
Available on crate features GKBasePlayer
and GKPlayer
and block2
only.
pub unsafe fn setRecipientResponseHandler( &self, recipient_response_handler: Option<&DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>>, )
GKBasePlayer
and GKPlayer
and block2
only.Setter for recipientResponseHandler
.
pub unsafe fn inviteeResponseHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>
block2
only.Sourcepub unsafe fn setInviteeResponseHandler(
&self,
invitee_response_handler: Option<&DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>>,
)
👎DeprecatedAvailable on crate feature block2
only.
pub unsafe fn setInviteeResponseHandler( &self, invitee_response_handler: Option<&DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>>, )
block2
only.Setter for inviteeResponseHandler
.
Sourcepub unsafe fn maxPlayersAllowedForMatchOfType(
match_type: GKMatchType,
) -> NSUInteger
pub unsafe fn maxPlayersAllowedForMatchOfType( match_type: GKMatchType, ) -> NSUInteger
To determine the maximum allowed players for each type of match supported.
pub unsafe fn playersToInvite(&self) -> Option<Retained<NSArray<NSString>>>
Sourcepub unsafe fn setPlayersToInvite(
&self,
players_to_invite: Option<&NSArray<NSString>>,
)
👎Deprecated
pub unsafe fn setPlayersToInvite( &self, players_to_invite: Option<&NSArray<NSString>>, )
Setter for playersToInvite
.
Sourcepub unsafe fn queueName(&self) -> Option<Retained<NSString>>
pub unsafe fn queueName(&self) -> Option<Retained<NSString>>
The name of the queue, if rule-based matchmaking is used.
Sourcepub unsafe fn setQueueName(&self, queue_name: Option<&NSString>)
pub unsafe fn setQueueName(&self, queue_name: Option<&NSString>)
Setter for queueName
.
Sourcepub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>
Available on crate feature GKDefines
only.
pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>
GKDefines
only.The match properties, if rule-based matchmaking is used.
Sourcepub unsafe fn setProperties(&self, properties: Option<&GKMatchProperties>)
Available on crate feature GKDefines
only.
pub unsafe fn setProperties(&self, properties: Option<&GKMatchProperties>)
GKDefines
only.Setter for properties
.
Sourcepub unsafe fn recipientProperties(
&self,
) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>
Available on crate features GKBasePlayer
and GKDefines
and GKPlayer
only.
pub unsafe fn recipientProperties( &self, ) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>
GKBasePlayer
and GKDefines
and GKPlayer
only.The recipient specific match properties, if rule-based matchmaking is used when inviting players.
Sourcepub unsafe fn setRecipientProperties(
&self,
recipient_properties: Option<&NSDictionary<GKPlayer, GKMatchProperties>>,
)
Available on crate features GKBasePlayer
and GKDefines
and GKPlayer
only.
pub unsafe fn setRecipientProperties( &self, recipient_properties: Option<&NSDictionary<GKPlayer, GKMatchProperties>>, )
GKBasePlayer
and GKDefines
and GKPlayer
only.Setter for recipientProperties
.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for GKMatchRequest
impl AsRef<AnyObject> for GKMatchRequest
Source§impl AsRef<GKMatchRequest> for GKMatchRequest
impl AsRef<GKMatchRequest> for GKMatchRequest
Source§impl AsRef<NSObject> for GKMatchRequest
impl AsRef<NSObject> for GKMatchRequest
Source§impl Borrow<AnyObject> for GKMatchRequest
impl Borrow<AnyObject> for GKMatchRequest
Source§impl Borrow<NSObject> for GKMatchRequest
impl Borrow<NSObject> for GKMatchRequest
Source§impl ClassType for GKMatchRequest
impl ClassType for GKMatchRequest
Source§const NAME: &'static str = "GKMatchRequest"
const NAME: &'static str = "GKMatchRequest"
Source§type ThreadKind = <<GKMatchRequest as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<GKMatchRequest as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for GKMatchRequest
impl Debug for GKMatchRequest
Source§impl Deref for GKMatchRequest
impl Deref for GKMatchRequest
Source§impl Hash for GKMatchRequest
impl Hash for GKMatchRequest
Source§impl Message for GKMatchRequest
impl Message for GKMatchRequest
Source§impl NSObjectProtocol for GKMatchRequest
impl NSObjectProtocol for GKMatchRequest
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref