Trait swift_rs::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§
sourcefn get_object(&self) -> &SRObject<Self::Shape>
fn get_object(&self) -> &SRObject<Self::Shape>
Gets a reference to the SRObject at the root of a SwiftObject
Provided Methods§
sourceunsafe fn swift_ref(&self) -> SwiftRef<'_, Self>where
Self: Sized,
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.