storekit/window.rs
1use core::ffi::c_void;
2use std::ptr::NonNull;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub struct NSWindowHandle(NonNull<c_void>);
6
7impl NSWindowHandle {
8 /// Wraps a caller-owned `NSWindow *` for `StoreKit` APIs that require a window.
9 ///
10 /// # Safety
11 ///
12 /// `ptr` must point to a live `NSWindow` for the duration of any `StoreKit` call that
13 /// borrows the returned handle. The handle does not retain the window and must not be
14 /// used after the underlying window has been deallocated.
15 pub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self> {
16 NonNull::new(ptr).map(Self)
17 }
18
19 pub const fn as_raw(&self) -> *mut c_void {
20 self.0.as_ptr()
21 }
22}