Skip to main content

ClassBuilder

Struct ClassBuilder 

Source
pub struct ClassBuilder { /* private fields */ }
Expand description

A class being built. Add methods, then register.

Implementations§

Source§

impl ClassBuilder

Source

pub unsafe fn new(superclass: &CStr, name: &CStr) -> Option<Self>

Begin a new class, or return None if the name is already taken.

§Safety

superclass must name a registered class.

Source

pub unsafe fn method( self, selector: &CStr, imp: *const c_void, types: &CStr, ) -> Self

Add a method.

types is an Objective-C type encoding: return type, then @: for the implicit receiver and selector, then one code per argument. B@:@@ is “returns BOOL, takes two objects”.

§Safety

imp’s signature must match types, receiver and selector included.

Source

pub unsafe fn conforms(self, protocol: &CStr) -> Self

Declare conformance to a protocol.

§Safety

The class must actually implement the protocol’s required methods.

Source

pub fn register(self) -> *mut c_void

Register the class with the runtime and return it.

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.