#[repr(C)]pub struct Class(_);
Expand description
A type that represents an Objective-C class.
Implementations
sourceimpl Class
impl Class
sourcepub fn get(name: &str) -> Option<&'static Self>
pub fn get(name: &str) -> Option<&'static Self>
Returns the class definition of a specified class, or None
if the
class is not registered with the Objective-C runtime.
sourcepub fn classes() -> Malloc<[&'static Self]>
Available on crate feature malloc
only.
pub fn classes() -> Malloc<[&'static Self]>
malloc
only.Obtains the list of registered class definitions.
sourcepub fn classes_count() -> usize
pub fn classes_count() -> usize
Returns the total number of registered classes.
sourcepub fn superclass(&self) -> Option<&Class>
pub fn superclass(&self) -> Option<&Class>
Returns the superclass of self, or None
if self is a root class.
sourcepub fn instance_size(&self) -> usize
pub fn instance_size(&self) -> usize
Returns the size of instances of self.
sourcepub fn instance_method(&self, sel: Sel) -> Option<&Method>
pub fn instance_method(&self, sel: Sel) -> Option<&Method>
Returns a specified instance method for self, or None
if self and
its superclasses do not contain an instance method with the specified
selector.
sourcepub fn instance_variable(&self, name: &str) -> Option<&Ivar>
pub fn instance_variable(&self, name: &str) -> Option<&Ivar>
Returns the ivar for a specified instance variable of self, or
None
if self has no ivar with the given name.
sourcepub fn instance_methods(&self) -> Malloc<[&Method]>
Available on crate feature malloc
only.
pub fn instance_methods(&self) -> Malloc<[&Method]>
malloc
only.Describes the instance methods implemented by self.
sourcepub fn conforms_to(&self, proto: &Protocol) -> bool
pub fn conforms_to(&self, proto: &Protocol) -> bool
Checks whether this class conforms to the specified protocol.
sourcepub fn adopted_protocols(&self) -> Malloc<[&Protocol]>
Available on crate feature malloc
only.
pub fn adopted_protocols(&self) -> Malloc<[&Protocol]>
malloc
only.Get a list of the protocols to which this class conforms.
sourcepub fn instance_variables(&self) -> Malloc<[&Ivar]>
Available on crate feature malloc
only.
pub fn instance_variables(&self) -> Malloc<[&Ivar]>
malloc
only.Describes the instance variables declared by self.
sourcepub fn responds_to(&self, sel: Sel) -> bool
pub fn responds_to(&self, sel: Sel) -> bool
Check whether instances of this class respond to the given selector.
This doesn’t call respondsToSelector:
, but works entirely within the
runtime, which means it’ll always be safe to call, but may not return
exactly what you’d expect if respondsToSelector:
has been
overwritten.
That said, it will always return true
if an instance of the class
responds to the selector, but may return false
if they don’t
directly (e.g. does so by using forwarding instead).
sourcepub fn verify_sel<A, R>(&self, sel: Sel) -> Result<(), VerificationError> where
A: EncodeArguments,
R: EncodeConvert,
Available on crate feature malloc
only.
pub fn verify_sel<A, R>(&self, sel: Sel) -> Result<(), VerificationError> where
A: EncodeArguments,
R: EncodeConvert,
malloc
only.Verify argument and return types for a given selector.
This will look up the encoding of the method for the given selector
and return a VerificationError
if any encodings differ for the
arguments A
and return type R
.
Example
let cls = class!(NSObject);
let sel = sel!(isKindOfClass:);
// Verify that `isKindOfClass:`:
// - Exists on the class
// - Takes a class as a parameter
// - Returns a BOOL
let result = cls.verify_sel::<(&Class,), bool>(sel);
assert!(result.is_ok());
Trait Implementations
sourceimpl<'a> MessageReceiver for &'a Class
impl<'a> MessageReceiver for &'a Class
sourceunsafe fn send_message<A, R>(self, sel: Sel, args: A) -> R where
A: MessageArguments,
R: EncodeConvert,
unsafe fn send_message<A, R>(self, sel: Sel, args: A) -> R where
A: MessageArguments,
R: EncodeConvert,
Sends a message to self with the given selector and arguments. Read more
sourceunsafe fn send_super_message<A, R>(
self,
superclass: &Class,
sel: Sel,
args: A
) -> R where
A: MessageArguments,
R: EncodeConvert,
unsafe fn send_super_message<A, R>(
self,
superclass: &Class,
sel: Sel,
args: A
) -> R where
A: MessageArguments,
R: EncodeConvert,
Sends a message to a specific superclass with the given selector and arguments. Read more
sourceimpl PartialEq<Class> for Class
impl PartialEq<Class> for Class
sourceimpl RefEncode for Class
impl RefEncode for Class
sourceconst ENCODING_REF: Encoding = Encoding::Class
const ENCODING_REF: Encoding = Encoding::Class
The Objective-C type-encoding for a reference of this type. Read more
impl Eq for Class
impl RefUnwindSafe for Class
impl Send for Class
impl Sync for Class
impl UnwindSafe for Class
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more