objc2_disk_arbitration/generated/
DASession.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12
13use crate::*;
14
15/// Type of a reference to DASession instances.
16///
17/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dasession?language=objc)
18#[doc(alias = "DASessionRef")]
19#[repr(C)]
20pub struct DASession {
21    inner: [u8; 0],
22    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
23}
24
25cf_type!(
26    unsafe impl DASession {}
27);
28#[cfg(feature = "objc2")]
29cf_objc2_type!(
30    unsafe impl RefEncode<"__DASession"> for DASession {}
31);
32
33unsafe impl ConcreteType for DASession {
34    /// Returns the type identifier of all DASession instances.
35    #[doc(alias = "DASessionGetTypeID")]
36    #[inline]
37    fn type_id() -> CFTypeID {
38        extern "C-unwind" {
39            fn DASessionGetTypeID() -> CFTypeID;
40        }
41        unsafe { DASessionGetTypeID() }
42    }
43}
44
45impl DASession {
46    /// Creates a new session.
47    ///
48    /// Returns: A reference to a new DASession.
49    ///
50    /// The caller of this function receives a reference to the returned object.  The
51    /// caller also implicitly retains the object and is responsible for releasing it.
52    #[doc(alias = "DASessionCreate")]
53    #[inline]
54    pub unsafe fn new(allocator: Option<&CFAllocator>) -> Option<CFRetained<DASession>> {
55        extern "C-unwind" {
56            fn DASessionCreate(allocator: Option<&CFAllocator>) -> Option<NonNull<DASession>>;
57        }
58        let ret = unsafe { DASessionCreate(allocator) };
59        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
60    }
61
62    /// Schedules the session on a run loop.
63    ///
64    /// Parameter `session`: The session which is being scheduled.
65    ///
66    /// Parameter `runLoop`: The run loop on which the session should be scheduled.
67    ///
68    /// Parameter `runLoopMode`: The run loop mode in which the session should be scheduled.
69    ///
70    /// # Safety
71    ///
72    /// `run_loop` possibly has additional threading requirements.
73    #[doc(alias = "DASessionScheduleWithRunLoop")]
74    #[inline]
75    pub unsafe fn schedule_with_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) {
76        extern "C-unwind" {
77            fn DASessionScheduleWithRunLoop(
78                session: &DASession,
79                run_loop: &CFRunLoop,
80                run_loop_mode: &CFString,
81            );
82        }
83        unsafe { DASessionScheduleWithRunLoop(self, run_loop, run_loop_mode) }
84    }
85
86    /// Unschedules the session from a run loop.
87    ///
88    /// Parameter `session`: The session which is being unscheduled.
89    ///
90    /// Parameter `runLoop`: The run loop on which the session is scheduled.
91    ///
92    /// Parameter `runLoopMode`: The run loop mode in which the session is scheduled.
93    ///
94    /// # Safety
95    ///
96    /// `run_loop` possibly has additional threading requirements.
97    #[doc(alias = "DASessionUnscheduleFromRunLoop")]
98    #[inline]
99    pub unsafe fn unschedule_from_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) {
100        extern "C-unwind" {
101            fn DASessionUnscheduleFromRunLoop(
102                session: &DASession,
103                run_loop: &CFRunLoop,
104                run_loop_mode: &CFString,
105            );
106        }
107        unsafe { DASessionUnscheduleFromRunLoop(self, run_loop, run_loop_mode) }
108    }
109
110    /// Schedules the session on a dispatch queue.
111    ///
112    /// Parameter `session`: The session which is being scheduled.
113    ///
114    /// Parameter `queue`: The dispatch queue on which the session should be scheduled.  Pass NULL to unschedule.
115    ///
116    /// # Safety
117    ///
118    /// `queue` possibly has additional threading requirements.
119    #[doc(alias = "DASessionSetDispatchQueue")]
120    #[cfg(feature = "dispatch2")]
121    #[inline]
122    pub unsafe fn set_dispatch_queue(&self, queue: Option<&DispatchQueue>) {
123        extern "C-unwind" {
124            fn DASessionSetDispatchQueue(session: &DASession, queue: Option<&DispatchQueue>);
125        }
126        unsafe { DASessionSetDispatchQueue(self, queue) }
127    }
128}
129
130/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/daapprovalsession?language=objc)
131#[doc(alias = "DAApprovalSessionRef")]
132#[repr(C)]
133pub struct DAApprovalSession {
134    inner: [u8; 0],
135    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
136}
137
138cf_type!(
139    unsafe impl DAApprovalSession {}
140);
141#[cfg(feature = "objc2")]
142cf_objc2_type!(
143    unsafe impl RefEncode<"__DASession"> for DAApprovalSession {}
144);
145
146unsafe impl ConcreteType for DAApprovalSession {
147    #[doc(alias = "DAApprovalSessionGetTypeID")]
148    #[inline]
149    fn type_id() -> CFTypeID {
150        extern "C-unwind" {
151            fn DAApprovalSessionGetTypeID() -> CFTypeID;
152        }
153        unsafe { DAApprovalSessionGetTypeID() }
154    }
155}
156
157impl DAApprovalSession {
158    #[doc(alias = "DAApprovalSessionCreate")]
159    #[inline]
160    pub unsafe fn new(allocator: Option<&CFAllocator>) -> Option<CFRetained<DAApprovalSession>> {
161        extern "C-unwind" {
162            fn DAApprovalSessionCreate(
163                allocator: Option<&CFAllocator>,
164            ) -> Option<NonNull<DAApprovalSession>>;
165        }
166        let ret = unsafe { DAApprovalSessionCreate(allocator) };
167        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
168    }
169
170    /// # Safety
171    ///
172    /// `run_loop` possibly has additional threading requirements.
173    #[doc(alias = "DAApprovalSessionScheduleWithRunLoop")]
174    #[inline]
175    pub unsafe fn schedule_with_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) {
176        extern "C-unwind" {
177            fn DAApprovalSessionScheduleWithRunLoop(
178                session: &DAApprovalSession,
179                run_loop: &CFRunLoop,
180                run_loop_mode: &CFString,
181            );
182        }
183        unsafe { DAApprovalSessionScheduleWithRunLoop(self, run_loop, run_loop_mode) }
184    }
185
186    /// # Safety
187    ///
188    /// `run_loop` possibly has additional threading requirements.
189    #[doc(alias = "DAApprovalSessionUnscheduleFromRunLoop")]
190    #[inline]
191    pub unsafe fn unschedule_from_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) {
192        extern "C-unwind" {
193            fn DAApprovalSessionUnscheduleFromRunLoop(
194                session: &DAApprovalSession,
195                run_loop: &CFRunLoop,
196                run_loop_mode: &CFString,
197            );
198        }
199        unsafe { DAApprovalSessionUnscheduleFromRunLoop(self, run_loop, run_loop_mode) }
200    }
201}
202
203#[deprecated = "renamed to `DASession::new`"]
204#[inline]
205pub unsafe extern "C-unwind" fn DASessionCreate(
206    allocator: Option<&CFAllocator>,
207) -> Option<CFRetained<DASession>> {
208    extern "C-unwind" {
209        fn DASessionCreate(allocator: Option<&CFAllocator>) -> Option<NonNull<DASession>>;
210    }
211    let ret = unsafe { DASessionCreate(allocator) };
212    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
213}
214
215extern "C-unwind" {
216    #[deprecated = "renamed to `DASession::schedule_with_run_loop`"]
217    pub fn DASessionScheduleWithRunLoop(
218        session: &DASession,
219        run_loop: &CFRunLoop,
220        run_loop_mode: &CFString,
221    );
222}
223
224extern "C-unwind" {
225    #[deprecated = "renamed to `DASession::unschedule_from_run_loop`"]
226    pub fn DASessionUnscheduleFromRunLoop(
227        session: &DASession,
228        run_loop: &CFRunLoop,
229        run_loop_mode: &CFString,
230    );
231}
232
233extern "C-unwind" {
234    #[cfg(feature = "dispatch2")]
235    #[deprecated = "renamed to `DASession::set_dispatch_queue`"]
236    pub fn DASessionSetDispatchQueue(session: &DASession, queue: Option<&DispatchQueue>);
237}
238
239#[deprecated = "renamed to `DAApprovalSession::new`"]
240#[inline]
241pub unsafe extern "C-unwind" fn DAApprovalSessionCreate(
242    allocator: Option<&CFAllocator>,
243) -> Option<CFRetained<DAApprovalSession>> {
244    extern "C-unwind" {
245        fn DAApprovalSessionCreate(
246            allocator: Option<&CFAllocator>,
247        ) -> Option<NonNull<DAApprovalSession>>;
248    }
249    let ret = unsafe { DAApprovalSessionCreate(allocator) };
250    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
251}
252
253extern "C-unwind" {
254    #[deprecated = "renamed to `DAApprovalSession::schedule_with_run_loop`"]
255    pub fn DAApprovalSessionScheduleWithRunLoop(
256        session: &DAApprovalSession,
257        run_loop: &CFRunLoop,
258        run_loop_mode: &CFString,
259    );
260}
261
262extern "C-unwind" {
263    #[deprecated = "renamed to `DAApprovalSession::unschedule_from_run_loop`"]
264    pub fn DAApprovalSessionUnscheduleFromRunLoop(
265        session: &DAApprovalSession,
266        run_loop: &CFRunLoop,
267        run_loop_mode: &CFString,
268    );
269}