pub struct SRObject<T>(/* private fields */);
Expand description
Wrapper for arbitrary NSObject
types.
When returning an NSObject
, its Rust type must be wrapped in SRObject
.
The type must also be annotated with #[repr(C)]
to ensure its memory layout
is identical to its Swift counterpart’s.
use swift_rs::{swift, SRObject, Int, Bool};
#[repr(C)]
struct CustomObject {
a: Int,
b: Bool
}
swift!(fn get_custom_object() -> SRObject<CustomObject>);
let value = unsafe { get_custom_object() };
let reference: &CustomObject = value.as_ref();
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SRObject<T>
impl<T> RefUnwindSafe for SRObject<T>where
T: RefUnwindSafe,
impl<T> !Send for SRObject<T>
impl<T> !Sync for SRObject<T>
impl<T> Unpin for SRObject<T>
impl<T> UnwindSafe for SRObject<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more