disk_arbitration_sys/session.rs
1use crate::prelude::*;
2
3#[repr(C)]
4#[derive(Debug, Copy, Clone)]
5pub struct __DASession {
6 _unused: [u8; 0],
7}
8
9/// Type of a reference to DASession instances.
10pub type DASessionRef = *mut __DASession;
11pub type DAApprovalSessionRef = *mut __DASession;
12
13extern "C" {
14 /// Returns the type identifier of all DASession instances.
15 pub fn DASessionGetTypeID() -> CFTypeID;
16
17 /// Creates a new session.
18 ///
19 /// # Returns
20 ///
21 /// A reference to a new DASession.
22 ///
23 /// # Discussion
24 ///
25 /// The caller of this function receives a reference to the returned object. The
26 /// caller also implicitly retains the object and is responsible for releasing it.
27 pub fn DASessionCreate(allocator: CFAllocatorRef) -> DASessionRef;
28
29 /// Schedules the session on a run loop.
30 ///
31 /// # Parameters
32 ///
33 /// * `session` - The session which is being scheduled.
34 /// * `runLoop` - The run loop on which the session should be scheduled.
35 /// * `runLoopMode` - The run loop mode in which the session should be scheduled.
36 pub fn DASessionScheduleWithRunLoop(
37 session: DASessionRef,
38 runLoop: CFRunLoopRef,
39 runLoopMode: CFStringRef,
40 );
41
42 /// Unschedules the session from a run loop.
43 ///
44 /// # Parameters
45 ///
46 /// * `session` - The session which is being unscheduled.
47 /// * `runLoop` - The run loop on which the session is scheduled.
48 /// * `runLoopMode` - The run loop mode in which the session is scheduled.
49 pub fn DASessionUnscheduleFromRunLoop(
50 session: DASessionRef,
51 runLoop: CFRunLoopRef,
52 runLoopMode: CFStringRef,
53 );
54
55 /// Schedules the session on a dispatch queue.
56 ///
57 /// # Parameters
58 ///
59 /// * `session` - The session which is being scheduled.
60 /// * `queue` - The dispatch queue on which the session should be scheduled. Pass NULL to unschedule.
61 pub fn DASessionSetDispatchQueue(session: DASessionRef, queue: dispatch_queue_t);
62
63 /// Registers a callback function to be called whenever a volume is to be unmounted.
64 ///
65 /// # Parameters
66 ///
67 /// * `session` - The session object.
68 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
69 /// * `callback` - The callback function to call when a volume is to be unmounted.
70 /// * `context` - The user-defined context parameter to pass to the callback function.
71 pub fn DARegisterDiskUnmountApprovalCallback(
72 session: DASessionRef,
73 match_: CFDictionaryRef,
74 callback: DADiskUnmountApprovalCallback,
75 context: *mut c_void,
76 );
77
78 /// Registers a callback function to be called whenever a volume is to be ejected.
79 ///
80 /// # Parameters
81 ///
82 /// * `session` - The session object.
83 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
84 /// * `callback` - The callback function to call when a volume is to be ejected.
85 /// * `context` - The user-defined context parameter to pass to the callback function.
86 pub fn DARegisterDiskEjectApprovalCallback(
87 session: DASessionRef,
88 match_: CFDictionaryRef,
89 callback: DADiskEjectApprovalCallback,
90 context: *mut c_void,
91 );
92
93 /// Registers a callback function to be called whenever a disk has been probed.
94 ///
95 /// # Parameters
96 ///
97 /// * `session` - The session object.
98 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
99 /// * `order` - The callback order, from lowest to highest. Pass 0 for the default.
100 /// * `callback` - The callback function to call when a disk has been probed.
101 /// * `context` - The user-defined context parameter to pass to the callback function.
102 pub fn DARegisterDiskPeekCallback(
103 session: DASessionRef,
104 match_: CFDictionaryRef,
105 order: CFIndex,
106 callback: DADiskPeekCallback,
107 context: *mut c_void,
108 );
109
110 /// Registers a callback function to be called whenever a volume is to be mounted.
111 ///
112 /// # Parameters
113 ///
114 /// * `session` - The session object.
115 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
116 /// * `callback` - The callback function to call when a volume is to be mounted.
117 /// * `context` - The user-defined context parameter to pass to the callback function.
118 pub fn DARegisterDiskMountApprovalCallback(
119 session: DASessionRef,
120 match_: CFDictionaryRef,
121 callback: DADiskMountApprovalCallback,
122 context: *mut c_void,
123 );
124
125 /// Registers a callback function to be called whenever a disk has disappeared.
126 ///
127 /// # Parameters
128 ///
129 /// * `session` - The session object.
130 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
131 /// * `callback` - The callback function to call when a disk has disappeared.
132 /// * `context` - The user-defined context parameter to pass to the callback function.
133 pub fn DARegisterDiskDisappearedCallback(
134 session: DASessionRef,
135 match_: CFDictionaryRef,
136 callback: DADiskDisappearedCallback,
137 context: *mut c_void,
138 );
139
140 /// Registers a callback function to be called whenever a disk has appeared.
141 ///
142 /// # Parameters
143 ///
144 /// * `session` - The session object.
145 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
146 /// * `callback` - The callback function to call when a disk has appeared.
147 /// * `context` - The user-defined context parameter to pass to the callback function.
148 pub fn DARegisterDiskAppearedCallback(
149 session: DASessionRef,
150 match_: CFDictionaryRef,
151 callback: DADiskAppearedCallback,
152 context: *mut c_void,
153 );
154
155 /// Registers a callback function to be called whenever a disk description has changed.
156 ///
157 /// # Parameters
158 ///
159 /// * `session` - The session object.
160 /// * `match` - The disk description keys to match. Pass NULL for all disk objects.
161 /// * `watch` - The disk description keys to watch. Pass NULL for all keys.
162 /// * `callback` - The callback function to call when a watched key changes.
163 /// * `context` - The user-defined context parameter to pass to the callback function.
164 pub fn DARegisterDiskDescriptionChangedCallback(
165 session: DASessionRef,
166 match_: CFDictionaryRef,
167 watch: CFArrayRef,
168 callback: DADiskDescriptionChangedCallback,
169 context: *mut c_void,
170 );
171
172 /// Unregisters a registered callback function.
173 ///
174 /// # Parameters
175 ///
176 /// * `session` - The session object.
177 /// * `callback` - The registered callback function.
178 /// * `context` - The user-defined context parameter.
179 pub fn DAUnregisterCallback(session: DASessionRef, callback: *mut c_void, context: *mut c_void);
180}
181
182extern "C" {
183 pub fn DAApprovalSessionGetTypeID() -> CFTypeID;
184 pub fn DAApprovalSessionCreate(allocator: CFAllocatorRef) -> DAApprovalSessionRef;
185 pub fn DAApprovalSessionScheduleWithRunLoop(
186 session: DAApprovalSessionRef,
187 runLoop: CFRunLoopRef,
188 runLoopMode: CFStringRef,
189 );
190 pub fn DAApprovalSessionUnscheduleFromRunLoop(
191 session: DAApprovalSessionRef,
192 runLoop: CFRunLoopRef,
193 runLoopMode: CFStringRef,
194 );
195 pub fn DAUnregisterApprovalCallback(
196 session: DASessionRef,
197 callback: *mut c_void,
198 context: *mut c_void,
199 );
200}