Trait SwiftObject

Source
pub trait SwiftObject {
    type Shape;

    // Required method
    fn get_object(&self) -> &SRObject<Self::Shape>;

    // Provided methods
    unsafe fn swift_ref(&self) -> SwiftRef<'_, Self>
       where Self: Sized { ... }
    unsafe fn retain(&self)
       where Self: Sized { ... }
}
Expand description

A type that is represented as an NSObject in Swift.

Required Associated Types§

Required Methods§

Source

fn get_object(&self) -> &SRObject<Self::Shape>

Gets a reference to the SRObject at the root of a SwiftObject

Provided Methods§

Source

unsafe fn swift_ref(&self) -> SwiftRef<'_, Self>
where Self: Sized,

Creates a SwiftRef for an object which can be used when calling a Swift function. This function should never be called manually, instead you should rely on the swift! macro to call it for you.

§Safety

This function converts the NonNull inside an SRObject into a reference, implicitly assuming that the pointer is still valid. The inner pointer is private, and the returned SwiftRef is bound to the lifetime of the original SRObject, so if you use swift-rs as normal this function should be safe.

Source

unsafe fn retain(&self)
where Self: Sized,

Adds a retain to an object.

§Safety

Just don’t call this, let swift! handle it for you.

Implementors§