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;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// Type of a reference to DASession instances.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dasession?language=objc)
14#[repr(C)]
15pub struct DASession {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    #[encoding_name = "__DASession"]
22    unsafe impl DASession {}
23);
24
25unsafe impl ConcreteType for DASession {
26    /// Returns the type identifier of all DASession instances.
27    #[doc(alias = "DASessionGetTypeID")]
28    #[inline]
29    fn type_id() -> CFTypeID {
30        extern "C-unwind" {
31            fn DASessionGetTypeID() -> CFTypeID;
32        }
33        unsafe { DASessionGetTypeID() }
34    }
35}
36
37/// Creates a new session.
38///
39/// Returns: A reference to a new DASession.
40///
41/// The caller of this function receives a reference to the returned object.  The
42/// caller also implicitly retains the object and is responsible for releasing it.
43#[inline]
44pub unsafe extern "C-unwind" fn DASessionCreate(
45    allocator: Option<&CFAllocator>,
46) -> Option<CFRetained<DASession>> {
47    extern "C-unwind" {
48        fn DASessionCreate(allocator: Option<&CFAllocator>) -> Option<NonNull<DASession>>;
49    }
50    let ret = unsafe { DASessionCreate(allocator) };
51    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
52}
53
54extern "C-unwind" {
55    /// Schedules the session on a run loop.
56    ///
57    /// Parameter `session`: The session which is being scheduled.
58    ///
59    /// Parameter `runLoop`: The run loop on which the session should be scheduled.
60    ///
61    /// Parameter `runLoopMode`: The run loop mode in which the session should be scheduled.
62    pub fn DASessionScheduleWithRunLoop(
63        session: &DASession,
64        run_loop: &CFRunLoop,
65        run_loop_mode: &CFString,
66    );
67}
68
69extern "C-unwind" {
70    /// Unschedules the session from a run loop.
71    ///
72    /// Parameter `session`: The session which is being unscheduled.
73    ///
74    /// Parameter `runLoop`: The run loop on which the session is scheduled.
75    ///
76    /// Parameter `runLoopMode`: The run loop mode in which the session is scheduled.
77    pub fn DASessionUnscheduleFromRunLoop(
78        session: &DASession,
79        run_loop: &CFRunLoop,
80        run_loop_mode: &CFString,
81    );
82}
83
84/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/daapprovalsession?language=objc)
85#[repr(C)]
86pub struct DAApprovalSession {
87    inner: [u8; 0],
88    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
89}
90
91cf_type!(
92    #[encoding_name = "__DASession"]
93    unsafe impl DAApprovalSession {}
94);
95
96unsafe impl ConcreteType for DAApprovalSession {
97    #[doc(alias = "DAApprovalSessionGetTypeID")]
98    #[inline]
99    fn type_id() -> CFTypeID {
100        extern "C-unwind" {
101            fn DAApprovalSessionGetTypeID() -> CFTypeID;
102        }
103        unsafe { DAApprovalSessionGetTypeID() }
104    }
105}
106
107#[inline]
108pub unsafe extern "C-unwind" fn DAApprovalSessionCreate(
109    allocator: Option<&CFAllocator>,
110) -> Option<CFRetained<DAApprovalSession>> {
111    extern "C-unwind" {
112        fn DAApprovalSessionCreate(
113            allocator: Option<&CFAllocator>,
114        ) -> Option<NonNull<DAApprovalSession>>;
115    }
116    let ret = unsafe { DAApprovalSessionCreate(allocator) };
117    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
118}
119
120extern "C-unwind" {
121    pub fn DAApprovalSessionScheduleWithRunLoop(
122        session: &DAApprovalSession,
123        run_loop: &CFRunLoop,
124        run_loop_mode: &CFString,
125    );
126}
127
128extern "C-unwind" {
129    pub fn DAApprovalSessionUnscheduleFromRunLoop(
130        session: &DAApprovalSession,
131        run_loop: &CFRunLoop,
132        run_loop_mode: &CFString,
133    );
134}