Struct Class

Source
#[repr(C)]
pub struct Class { /* private fields */ }
Expand description

An Objective-C class.

See documentation.

§Usage

This is an opaque type meant to be used behind a shared reference &Class, which is semantically equivalent to Class _Nonnull.

A nullable class is defined as Option<&Class>, which is semantically equivalent to Class _Nullable.

Implementations§

Source§

impl Class

Source

pub fn get(name: &CStr) -> Option<&'static Class>

Returns the class definition of a specified class, or None if the class is not registered with the Objective-C runtime.

Source

pub fn count() -> usize

Returns the number of classes registered with the Objective-C runtime.

Source

pub fn all() -> Vec<&'static Class>

Returns all classes registered with the Objective-C runtime.

Source

pub fn responds_to_selector(&self, selector: Sel) -> bool

Returns true if this class implements or inherits a method that can respond to a specified message.

See documentation.

Source

pub fn instances_respond_to_selector(&self, selector: Sel) -> bool

Returns true if instances of this class implement or inherit a method that can respond to a specified message.

See documentation.

Source

pub fn name(&self) -> &CStr

Returns the name of this class.

Source

pub fn superclass(&self) -> Option<&Class>

Returns this class’s superclass, or None if this is a root class (e.g. NSObject).

Source

pub fn superclass_iter(&self) -> impl Iterator<Item = &Class> + Copy

Returns an iterator over the superclasses of this class.

Source

pub fn superclass_count(&self) -> usize

Returns the number of superclasses of this class.

Source

pub fn is_subclass(&self) -> bool

Returns true if this class has a superclass.

Source

pub fn is_subclass_of(&self, other: &Self) -> bool

Returns true if this class is a subclass of, or identical to, the other class.

Source

pub fn instance_size(&self) -> usize

Returns the size of instances of this class.

Source

pub fn get_class_method(&self, name: Sel) -> Option<&Method>

Returns a reference to the data for a class method defined by name, or None if this class or its superclasses do not implement a class method with the specified selector.

Note that this function searches superclasses for implementations, whereas copy_class_method_list does not.

See documentation.

Source

pub fn copy_class_method_list(&self) -> Option<Malloced<[&Method]>>

Returns the class methods implemented by this class, or None if this class implements no instance methods.

To get the implementations of instance methods that may be implemented by superclasses, use get_class_method.

This calls class_copyMethodList on the metaclass of this class.

Source

pub fn get_instance_method(&self, name: Sel) -> Option<&Method>

Returns a reference to the data for an instance method defined by name, or None if this class or its superclasses do not implement an instance method with the specified selector.

Note that this function searches superclasses for implementations, whereas copy_instance_method_list does not.

See documentation.

Source

pub fn copy_instance_method_list(&self) -> Option<Malloced<[&Method]>>

Returns the instance methods implemented by this class, or None if this class implements no instance methods.

To get the implementations of instance methods that may be implemented by superclasses, use get_instance_method.

See documentation.

Source

pub fn get_property<'a>(&'a self, name: &CStr) -> Option<&'a Property>

Returns a property of self with name.

See documentation.

Source

pub fn copy_property_list(&self) -> Option<Malloced<[&Property]>>

Returns a malloc-ed list of properties declared by self.

Any properties declared by superclasses are not included.

See documentation.

Trait Implementations§

Source§

impl Debug for Class

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Class

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Class

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Class

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Class

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Class

Source§

impl RefUnwindSafe for Class

Source§

impl Send for Class

Source§

impl Sync for Class

Auto Trait Implementations§

§

impl !Freeze for Class

§

impl Unpin for Class

§

impl UnwindSafe for Class

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.