objc2_disk_arbitration/generated/mod.rs
1// This file has been automatically generated by `objc2`'s `header-translator`.
2// DO NOT EDIT
3
4#![allow(unused_imports)]
5#![allow(deprecated)]
6#![allow(non_snake_case)]
7#![allow(non_camel_case_types)]
8#![allow(non_upper_case_globals)]
9#![allow(missing_docs)]
10#![allow(clippy::too_many_arguments)]
11#![allow(clippy::type_complexity)]
12#![allow(clippy::upper_case_acronyms)]
13#![allow(clippy::identity_op)]
14#![allow(clippy::missing_safety_doc)]
15#![allow(clippy::doc_lazy_continuation)]
16#![allow(rustdoc::broken_intra_doc_links)]
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::unportable_markdown)]
19#![allow(rustdoc::invalid_html_tags)]
20
21#[link(name = "DiskArbitration", kind = "framework")]
22extern "C" {}
23
24#[cfg(feature = "DADisk")]
25#[path = "DADisk.rs"]
26mod __DADisk;
27#[cfg(feature = "DADissenter")]
28#[path = "DADissenter.rs"]
29mod __DADissenter;
30#[cfg(feature = "DASession")]
31#[path = "DASession.rs"]
32mod __DASession;
33
34#[cfg(feature = "DADisk")]
35pub use self::__DADisk::kDADiskDescriptionBusNameKey;
36#[cfg(feature = "DADisk")]
37pub use self::__DADisk::kDADiskDescriptionBusPathKey;
38#[cfg(feature = "DADisk")]
39pub use self::__DADisk::kDADiskDescriptionDeviceGUIDKey;
40#[cfg(feature = "DADisk")]
41pub use self::__DADisk::kDADiskDescriptionDeviceInternalKey;
42#[cfg(feature = "DADisk")]
43pub use self::__DADisk::kDADiskDescriptionDeviceModelKey;
44#[cfg(feature = "DADisk")]
45pub use self::__DADisk::kDADiskDescriptionDevicePathKey;
46#[cfg(feature = "DADisk")]
47pub use self::__DADisk::kDADiskDescriptionDeviceProtocolKey;
48#[cfg(feature = "DADisk")]
49pub use self::__DADisk::kDADiskDescriptionDeviceRevisionKey;
50#[cfg(feature = "DADisk")]
51pub use self::__DADisk::kDADiskDescriptionDeviceTDMLockedKey;
52#[cfg(feature = "DADisk")]
53pub use self::__DADisk::kDADiskDescriptionDeviceUnitKey;
54#[cfg(feature = "DADisk")]
55pub use self::__DADisk::kDADiskDescriptionDeviceVendorKey;
56#[cfg(feature = "DADisk")]
57pub use self::__DADisk::kDADiskDescriptionFSKitPrefix;
58#[cfg(feature = "DADisk")]
59pub use self::__DADisk::kDADiskDescriptionMediaBSDMajorKey;
60#[cfg(feature = "DADisk")]
61pub use self::__DADisk::kDADiskDescriptionMediaBSDMinorKey;
62#[cfg(feature = "DADisk")]
63pub use self::__DADisk::kDADiskDescriptionMediaBSDNameKey;
64#[cfg(feature = "DADisk")]
65pub use self::__DADisk::kDADiskDescriptionMediaBSDUnitKey;
66#[cfg(feature = "DADisk")]
67pub use self::__DADisk::kDADiskDescriptionMediaBlockSizeKey;
68#[cfg(feature = "DADisk")]
69pub use self::__DADisk::kDADiskDescriptionMediaContentKey;
70#[cfg(feature = "DADisk")]
71pub use self::__DADisk::kDADiskDescriptionMediaEjectableKey;
72#[cfg(feature = "DADisk")]
73pub use self::__DADisk::kDADiskDescriptionMediaEncryptedKey;
74#[cfg(feature = "DADisk")]
75pub use self::__DADisk::kDADiskDescriptionMediaEncryptionDetailKey;
76#[cfg(feature = "DADisk")]
77pub use self::__DADisk::kDADiskDescriptionMediaIconKey;
78#[cfg(feature = "DADisk")]
79pub use self::__DADisk::kDADiskDescriptionMediaKindKey;
80#[cfg(feature = "DADisk")]
81pub use self::__DADisk::kDADiskDescriptionMediaLeafKey;
82#[cfg(feature = "DADisk")]
83pub use self::__DADisk::kDADiskDescriptionMediaNameKey;
84#[cfg(feature = "DADisk")]
85pub use self::__DADisk::kDADiskDescriptionMediaPathKey;
86#[cfg(feature = "DADisk")]
87pub use self::__DADisk::kDADiskDescriptionMediaRemovableKey;
88#[cfg(feature = "DADisk")]
89pub use self::__DADisk::kDADiskDescriptionMediaSizeKey;
90#[cfg(feature = "DADisk")]
91pub use self::__DADisk::kDADiskDescriptionMediaTypeKey;
92#[cfg(feature = "DADisk")]
93pub use self::__DADisk::kDADiskDescriptionMediaUUIDKey;
94#[cfg(feature = "DADisk")]
95pub use self::__DADisk::kDADiskDescriptionMediaWholeKey;
96#[cfg(feature = "DADisk")]
97pub use self::__DADisk::kDADiskDescriptionMediaWritableKey;
98#[cfg(feature = "DADisk")]
99pub use self::__DADisk::kDADiskDescriptionVolumeKindKey;
100#[cfg(feature = "DADisk")]
101pub use self::__DADisk::kDADiskDescriptionVolumeMountableKey;
102#[cfg(feature = "DADisk")]
103pub use self::__DADisk::kDADiskDescriptionVolumeNameKey;
104#[cfg(feature = "DADisk")]
105pub use self::__DADisk::kDADiskDescriptionVolumeNetworkKey;
106#[cfg(feature = "DADisk")]
107pub use self::__DADisk::kDADiskDescriptionVolumePathKey;
108#[cfg(feature = "DADisk")]
109pub use self::__DADisk::kDADiskDescriptionVolumeTypeKey;
110#[cfg(feature = "DADisk")]
111pub use self::__DADisk::kDADiskDescriptionVolumeUUIDKey;
112#[cfg(feature = "DADisk")]
113pub use self::__DADisk::DADisk;
114#[cfg(feature = "DADisk")]
115pub use self::__DADisk::DADiskCopyDescription;
116#[cfg(feature = "DADisk")]
117pub use self::__DADisk::DADiskCopyWholeDisk;
118#[cfg(all(feature = "DADisk", feature = "DASession"))]
119pub use self::__DADisk::DADiskCreateFromBSDName;
120#[cfg(all(feature = "DADisk", feature = "DASession"))]
121pub use self::__DADisk::DADiskCreateFromVolumePath;
122#[cfg(feature = "DADisk")]
123pub use self::__DADisk::DADiskGetBSDName;
124#[cfg(feature = "DADissenter")]
125pub use self::__DADissenter::kDAReturnBadArgument;
126#[cfg(feature = "DADissenter")]
127pub use self::__DADissenter::kDAReturnBusy;
128#[cfg(feature = "DADissenter")]
129pub use self::__DADissenter::kDAReturnError;
130#[cfg(feature = "DADissenter")]
131pub use self::__DADissenter::kDAReturnExclusiveAccess;
132#[cfg(feature = "DADissenter")]
133pub use self::__DADissenter::kDAReturnNoResources;
134#[cfg(feature = "DADissenter")]
135pub use self::__DADissenter::kDAReturnNotFound;
136#[cfg(feature = "DADissenter")]
137pub use self::__DADissenter::kDAReturnNotMounted;
138#[cfg(feature = "DADissenter")]
139pub use self::__DADissenter::kDAReturnNotPermitted;
140#[cfg(feature = "DADissenter")]
141pub use self::__DADissenter::kDAReturnNotPrivileged;
142#[cfg(feature = "DADissenter")]
143pub use self::__DADissenter::kDAReturnNotReady;
144#[cfg(feature = "DADissenter")]
145pub use self::__DADissenter::kDAReturnNotWritable;
146#[cfg(feature = "DADissenter")]
147pub use self::__DADissenter::kDAReturnSuccess;
148#[cfg(feature = "DADissenter")]
149pub use self::__DADissenter::kDAReturnUnsupported;
150#[cfg(feature = "DADissenter")]
151pub use self::__DADissenter::DADissenter;
152#[cfg(all(feature = "DADissenter", feature = "libc"))]
153pub use self::__DADissenter::DADissenterCreate;
154#[cfg(all(feature = "DADissenter", feature = "libc"))]
155pub use self::__DADissenter::DADissenterGetStatus;
156#[cfg(feature = "DADissenter")]
157pub use self::__DADissenter::DADissenterGetStatusString;
158#[cfg(all(feature = "DADissenter", feature = "libc"))]
159pub use self::__DADissenter::DAReturn;
160#[cfg(feature = "DASession")]
161pub use self::__DASession::DAApprovalSession;
162#[cfg(feature = "DASession")]
163pub use self::__DASession::DAApprovalSessionCreate;
164#[cfg(feature = "DASession")]
165pub use self::__DASession::DAApprovalSessionScheduleWithRunLoop;
166#[cfg(feature = "DASession")]
167pub use self::__DASession::DAApprovalSessionUnscheduleFromRunLoop;
168#[cfg(feature = "DASession")]
169pub use self::__DASession::DASession;
170#[cfg(feature = "DASession")]
171pub use self::__DASession::DASessionCreate;
172#[cfg(feature = "DASession")]
173pub use self::__DASession::DASessionScheduleWithRunLoop;
174#[cfg(feature = "DASession")]
175pub use self::__DASession::DASessionUnscheduleFromRunLoop;
176use core::ffi::*;
177use core::ptr::NonNull;
178use objc2_core_foundation::*;
179
180use crate::*;
181
182/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskmountoptiondefault?language=objc)
183pub const kDADiskMountOptionDefault: c_uint = 0x00000000;
184/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskmountoptionwhole?language=objc)
185pub const kDADiskMountOptionWhole: c_uint = 0x00000001;
186/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskmountoptionnofollow?language=objc)
187pub const kDADiskMountOptionNoFollow: c_uint = 0x00000002;
188
189/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskmountoptions?language=objc)
190pub type DADiskMountOptions = u32;
191
192/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskrenameoptiondefault?language=objc)
193pub const kDADiskRenameOptionDefault: c_uint = 0x00000000;
194
195/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskrenameoptions?language=objc)
196pub type DADiskRenameOptions = u32;
197
198/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskunmountoptiondefault?language=objc)
199pub const kDADiskUnmountOptionDefault: c_uint = 0x00000000;
200/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskunmountoptionforce?language=objc)
201pub const kDADiskUnmountOptionForce: c_uint = 0x00080000;
202/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskunmountoptionwhole?language=objc)
203pub const kDADiskUnmountOptionWhole: c_uint = 0x00000001;
204
205/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskunmountoptions?language=objc)
206pub type DADiskUnmountOptions = u32;
207
208/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskejectoptiondefault?language=objc)
209pub const kDADiskEjectOptionDefault: c_uint = 0x00000000;
210
211/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskejectoptions?language=objc)
212pub type DADiskEjectOptions = u32;
213
214/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskclaimoptiondefault?language=objc)
215pub const kDADiskClaimOptionDefault: c_uint = 0x00000000;
216
217/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskclaimoptions?language=objc)
218pub type DADiskClaimOptions = u32;
219
220/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskoptiondefault?language=objc)
221pub const kDADiskOptionDefault: c_uint = 0x00000000;
222
223/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskoptions?language=objc)
224pub type DADiskOptions = u32;
225
226extern "C" {
227 /// Predefined CFDictionary object containing a set of disk description keys and values
228 /// appropriate for matching unformatted media using DARegister*Callback().
229 ///
230 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchmediaunformatted?language=objc)
231 pub static kDADiskDescriptionMatchMediaUnformatted: &'static CFDictionary;
232}
233
234extern "C" {
235 /// Predefined CFDictionary object containing a set of disk description keys and values
236 /// appropriate for matching whole media using DARegister*Callback().
237 ///
238 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchmediawhole?language=objc)
239 pub static kDADiskDescriptionMatchMediaWhole: &'static CFDictionary;
240}
241
242extern "C" {
243 /// Predefined CFDictionary object containing a set of disk description keys and values
244 /// appropriate for matching mountable volumes using DARegister*Callback().
245 ///
246 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchvolumemountable?language=objc)
247 pub static kDADiskDescriptionMatchVolumeMountable: &'static CFDictionary;
248}
249
250extern "C" {
251 /// Predefined CFDictionary object containing a set of disk description keys and values
252 /// appropriate for matching unrecognized volumes using DARegister*Callback().
253 ///
254 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchvolumeunrecognized?language=objc)
255 pub static kDADiskDescriptionMatchVolumeUnrecognized: &'static CFDictionary;
256}
257
258extern "C" {
259 /// Predefined CFArray object containing a set of disk description keys appropriate for
260 /// watching volume name changes using DARegisterDiskDescriptionChangedCallback().
261 ///
262 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionwatchvolumename?language=objc)
263 pub static kDADiskDescriptionWatchVolumeName: &'static CFArray;
264}
265
266extern "C" {
267 /// Predefined CFArray object containing a set of disk description keys appropriate for
268 /// watching volume mount changes using DARegisterDiskDescriptionChangedCallback().
269 ///
270 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionwatchvolumepath?language=objc)
271 pub static kDADiskDescriptionWatchVolumePath: &'static CFArray;
272}
273
274/// Type of the callback function used by DARegisterDiskAppearedCallback().
275///
276/// Parameter `disk`: A disk object.
277///
278/// Parameter `context`: The user-defined context parameter given to the registration function.
279///
280/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskappearedcallback?language=objc)
281#[cfg(feature = "DADisk")]
282pub type DADiskAppearedCallback = Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void)>;
283
284extern "C-unwind" {
285 /// Registers a callback function to be called whenever a disk has appeared.
286 ///
287 /// Parameter `session`: The session object.
288 ///
289 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
290 ///
291 /// Parameter `callback`: The callback function to call when a disk has appeared.
292 ///
293 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
294 #[cfg(all(feature = "DADisk", feature = "DASession"))]
295 pub fn DARegisterDiskAppearedCallback(
296 session: &DASession,
297 r#match: Option<&CFDictionary>,
298 callback: DADiskAppearedCallback,
299 context: *mut c_void,
300 );
301}
302
303/// Type of the callback function used by DARegisterDiskDescriptionChangedCallback().
304///
305/// Parameter `disk`: A disk object.
306///
307/// Parameter `keys`: A list of changed keys.
308///
309/// Parameter `context`: The user-defined context parameter given to the registration function.
310///
311/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskdescriptionchangedcallback?language=objc)
312#[cfg(feature = "DADisk")]
313pub type DADiskDescriptionChangedCallback =
314 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, NonNull<CFArray>, *mut c_void)>;
315
316extern "C-unwind" {
317 /// Registers a callback function to be called whenever a disk description has changed.
318 ///
319 /// Parameter `session`: The session object.
320 ///
321 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
322 ///
323 /// Parameter `watch`: The disk description keys to watch. Pass NULL for all keys.
324 ///
325 /// Parameter `callback`: The callback function to call when a watched key changes.
326 ///
327 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
328 #[cfg(all(feature = "DADisk", feature = "DASession"))]
329 pub fn DARegisterDiskDescriptionChangedCallback(
330 session: &DASession,
331 r#match: Option<&CFDictionary>,
332 watch: Option<&CFArray>,
333 callback: DADiskDescriptionChangedCallback,
334 context: *mut c_void,
335 );
336}
337
338/// Type of the callback function used by DARegisterDiskDisappearedCallback().
339///
340/// Parameter `disk`: A disk object.
341///
342/// Parameter `context`: The user-defined context parameter given to the registration function.
343///
344/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskdisappearedcallback?language=objc)
345#[cfg(feature = "DADisk")]
346pub type DADiskDisappearedCallback =
347 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void)>;
348
349extern "C-unwind" {
350 /// Registers a callback function to be called whenever a disk has disappeared.
351 ///
352 /// Parameter `session`: The session object.
353 ///
354 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
355 ///
356 /// Parameter `callback`: The callback function to call when a disk has disappeared.
357 ///
358 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
359 #[cfg(all(feature = "DADisk", feature = "DASession"))]
360 pub fn DARegisterDiskDisappearedCallback(
361 session: &DASession,
362 r#match: Option<&CFDictionary>,
363 callback: DADiskDisappearedCallback,
364 context: *mut c_void,
365 );
366}
367
368/// Type of the callback function used by DADiskMount().
369///
370/// Parameter `disk`: The disk object.
371///
372/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
373///
374/// Parameter `context`: The user-defined context parameter given to the mount function.
375///
376/// If the disk is already mounted, then status code in the dissenter object will be set to kDAReturnBusy
377///
378/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskmountcallback?language=objc)
379#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
380pub type DADiskMountCallback =
381 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
382
383extern "C-unwind" {
384 /// Mounts the volume at the specified disk object.
385 ///
386 /// Parameter `disk`: The disk object.
387 ///
388 /// Parameter `path`: The mount path. Pass NULL for a "standard" mount path.
389 ///
390 /// Parameter `options`: The mount options.
391 ///
392 /// Parameter `callback`: The callback function to call once the mount completes.
393 ///
394 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
395 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
396 pub fn DADiskMount(
397 disk: &DADisk,
398 path: Option<&CFURL>,
399 options: DADiskMountOptions,
400 callback: DADiskMountCallback,
401 context: *mut c_void,
402 );
403}
404
405extern "C-unwind" {
406 /// Mounts the volume at the specified disk object, with the specified mount options.
407 ///
408 /// Parameter `disk`: The disk object.
409 ///
410 /// Parameter `path`: The mount path. Pass NULL for a "standard" mount path.
411 ///
412 /// Parameter `options`: The mount options.
413 ///
414 /// Parameter `callback`: The callback function to call once the mount completes.
415 ///
416 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
417 ///
418 /// Parameter `arguments`: The null-terminated list of mount options to pass to /sbin/mount -o.
419 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
420 pub fn DADiskMountWithArguments(
421 disk: &DADisk,
422 path: Option<&CFURL>,
423 options: DADiskMountOptions,
424 callback: DADiskMountCallback,
425 context: *mut c_void,
426 arguments: *mut *const CFString,
427 );
428}
429
430/// Type of the callback function used by DARegisterDiskMountApprovalCallback().
431///
432/// Parameter `disk`: A disk object.
433///
434/// Parameter `context`: The user-defined context parameter given to the registration function.
435///
436/// Returns: A dissenter reference. Pass NULL to approve.
437///
438/// The caller of this callback receives a reference to the returned object. The
439/// caller also implicitly retains the object and is responsible for releasing it
440/// with CFRelease().
441///
442/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskmountapprovalcallback?language=objc)
443#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
444pub type DADiskMountApprovalCallback =
445 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
446
447extern "C-unwind" {
448 /// Registers a callback function to be called whenever a volume is to be mounted.
449 ///
450 /// Parameter `session`: The session object.
451 ///
452 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
453 ///
454 /// Parameter `callback`: The callback function to call when a volume is to be mounted.
455 ///
456 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
457 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "DASession"))]
458 pub fn DARegisterDiskMountApprovalCallback(
459 session: &DASession,
460 r#match: Option<&CFDictionary>,
461 callback: DADiskMountApprovalCallback,
462 context: *mut c_void,
463 );
464}
465
466/// Type of the callback function used by DADiskRename().
467///
468/// Parameter `disk`: The disk object.
469///
470/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
471///
472/// Parameter `context`: The user-defined context parameter given to the rename function.
473///
474/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskrenamecallback?language=objc)
475#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
476pub type DADiskRenameCallback =
477 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
478
479extern "C-unwind" {
480 /// Renames the volume at the specified disk object.
481 ///
482 /// Parameter `disk`: The disk object.
483 ///
484 /// Parameter `options`: The rename options.
485 ///
486 /// Parameter `callback`: The callback function to call once the rename completes.
487 ///
488 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
489 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
490 pub fn DADiskRename(
491 disk: &DADisk,
492 name: &CFString,
493 options: DADiskRenameOptions,
494 callback: DADiskRenameCallback,
495 context: *mut c_void,
496 );
497}
498
499/// Type of the callback function used by DADiskUnmount().
500///
501/// Parameter `disk`: The disk object.
502///
503/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
504///
505/// Parameter `context`: The user-defined context parameter given to the unmount function.
506///
507/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskunmountcallback?language=objc)
508#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
509pub type DADiskUnmountCallback =
510 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
511
512extern "C-unwind" {
513 /// Unmounts the volume at the specified disk object.
514 ///
515 /// Parameter `disk`: The disk object.
516 ///
517 /// Parameter `options`: The unmount options.
518 ///
519 /// Parameter `callback`: The callback function to call once the unmount completes.
520 ///
521 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
522 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
523 pub fn DADiskUnmount(
524 disk: &DADisk,
525 options: DADiskUnmountOptions,
526 callback: DADiskUnmountCallback,
527 context: *mut c_void,
528 );
529}
530
531/// Type of the callback function used by DARegisterDiskUnmountApprovalCallback().
532///
533/// Parameter `disk`: A disk object.
534///
535/// Parameter `context`: The user-defined context parameter given to the registration function.
536///
537/// Returns: A dissenter reference. Pass NULL to approve.
538///
539/// The caller of this callback receives a reference to the returned object. The
540/// caller also implicitly retains the object and is responsible for releasing it
541/// with CFRelease().
542///
543/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskunmountapprovalcallback?language=objc)
544#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
545pub type DADiskUnmountApprovalCallback =
546 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
547
548extern "C-unwind" {
549 /// Registers a callback function to be called whenever a volume is to be unmounted.
550 ///
551 /// Parameter `session`: The session object.
552 ///
553 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
554 ///
555 /// Parameter `callback`: The callback function to call when a volume is to be unmounted.
556 ///
557 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
558 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "DASession"))]
559 pub fn DARegisterDiskUnmountApprovalCallback(
560 session: &DASession,
561 r#match: Option<&CFDictionary>,
562 callback: DADiskUnmountApprovalCallback,
563 context: *mut c_void,
564 );
565}
566
567/// Type of the callback function used by DADiskEject().
568///
569/// Parameter `disk`: The disk object.
570///
571/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
572///
573/// Parameter `context`: The user-defined context parameter given to the eject function.
574///
575/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskejectcallback?language=objc)
576#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
577pub type DADiskEjectCallback =
578 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
579
580extern "C-unwind" {
581 /// Ejects the specified disk object.
582 ///
583 /// Parameter `disk`: The disk object.
584 ///
585 /// Parameter `options`: The eject options.
586 ///
587 /// Parameter `callback`: The callback function to call once the ejection completes.
588 ///
589 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
590 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
591 pub fn DADiskEject(
592 disk: &DADisk,
593 options: DADiskEjectOptions,
594 callback: DADiskEjectCallback,
595 context: *mut c_void,
596 );
597}
598
599/// Type of the callback function used by DARegisterDiskEjectApprovalCallback().
600///
601/// Parameter `disk`: A disk object.
602///
603/// Parameter `context`: The user-defined context parameter given to the registration function.
604///
605/// Returns: A dissenter reference. Pass NULL to approve.
606///
607/// The caller of this callback receives a reference to the returned object. The
608/// caller also implicitly retains the object and is responsible for releasing it
609/// with CFRelease().
610///
611/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskejectapprovalcallback?language=objc)
612#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
613pub type DADiskEjectApprovalCallback =
614 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
615
616extern "C-unwind" {
617 /// Registers a callback function to be called whenever a volume is to be ejected.
618 ///
619 /// Parameter `session`: The session object.
620 ///
621 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
622 ///
623 /// Parameter `callback`: The callback function to call when a volume is to be ejected.
624 ///
625 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
626 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "DASession"))]
627 pub fn DARegisterDiskEjectApprovalCallback(
628 session: &DASession,
629 r#match: Option<&CFDictionary>,
630 callback: DADiskEjectApprovalCallback,
631 context: *mut c_void,
632 );
633}
634
635/// Type of the callback function used by DADiskClaim().
636///
637/// Parameter `disk`: The disk object.
638///
639/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
640///
641/// Parameter `context`: The user-defined context parameter given to the claim function.
642///
643/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskclaimcallback?language=objc)
644#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
645pub type DADiskClaimCallback =
646 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
647
648/// Type of the callback function used by DADiskClaim().
649///
650/// Parameter `disk`: The disk object.
651///
652/// Parameter `context`: The user-defined context parameter given to the claim function.
653///
654/// Returns: A dissenter reference. Pass NULL to release claim.
655///
656/// The caller of this callback receives a reference to the returned object. The
657/// caller also implicitly retains the object and is responsible for releasing it
658/// with CFRelease().
659///
660/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskclaimreleasecallback?language=objc)
661#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
662pub type DADiskClaimReleaseCallback =
663 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
664
665extern "C-unwind" {
666 /// Claims the specified disk object for exclusive use.
667 ///
668 /// Parameter `disk`: The disk object.
669 ///
670 /// Parameter `options`: The claim options.
671 ///
672 /// Parameter `release`: The callback function to call when the claim is to be released.
673 ///
674 /// Parameter `releaseContext`: The user-defined context parameter to pass to the callback function.
675 ///
676 /// Parameter `callback`: The callback function to call once the claim completes.
677 ///
678 /// Parameter `callbackContext`: The user-defined context parameter to pass to the callback function.
679 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
680 pub fn DADiskClaim(
681 disk: &DADisk,
682 options: DADiskClaimOptions,
683 release: DADiskClaimReleaseCallback,
684 release_context: *mut c_void,
685 callback: DADiskClaimCallback,
686 callback_context: *mut c_void,
687 );
688}
689
690/// Reports whether or not the disk is claimed.
691///
692/// Parameter `disk`: The disk object.
693///
694/// Returns: TRUE if the disk is claimed, otherwise FALSE.
695#[cfg(feature = "DADisk")]
696#[inline]
697pub unsafe extern "C-unwind" fn DADiskIsClaimed(disk: &DADisk) -> bool {
698 extern "C-unwind" {
699 fn DADiskIsClaimed(disk: &DADisk) -> Boolean;
700 }
701 let ret = unsafe { DADiskIsClaimed(disk) };
702 ret != 0
703}
704
705extern "C-unwind" {
706 /// Unclaims the specified disk object.
707 ///
708 /// Parameter `disk`: The disk object.
709 #[cfg(feature = "DADisk")]
710 pub fn DADiskUnclaim(disk: &DADisk);
711}
712
713/// Type of the callback function used by DARegisterDiskPeekCallback().
714///
715/// Parameter `disk`: A disk object.
716///
717/// Parameter `context`: The user-defined context parameter given to the registration function.
718///
719/// The peek callback functions are called in a specific order, from lowest order to highest
720/// order. DADiskClaim() could be used here to claim the disk object and DADiskSetOptions()
721/// could be used here to set up options on the disk object.
722///
723/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskpeekcallback?language=objc)
724#[cfg(feature = "DADisk")]
725pub type DADiskPeekCallback = Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void)>;
726
727extern "C-unwind" {
728 /// Registers a callback function to be called whenever a disk has been probed.
729 ///
730 /// Parameter `session`: The session object.
731 ///
732 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
733 ///
734 /// Parameter `order`: The callback order, from lowest to highest. Pass 0 for the default.
735 ///
736 /// Parameter `callback`: The callback function to call when a disk has been probed.
737 ///
738 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
739 #[cfg(all(feature = "DADisk", feature = "DASession"))]
740 pub fn DARegisterDiskPeekCallback(
741 session: &DASession,
742 r#match: Option<&CFDictionary>,
743 order: CFIndex,
744 callback: DADiskPeekCallback,
745 context: *mut c_void,
746 );
747}
748
749extern "C-unwind" {
750 /// Obtains the options for the specified disk.
751 ///
752 /// Parameter `disk`: The disk object for which to obtain the options.
753 ///
754 /// Returns: The options.
755 #[cfg(feature = "DADisk")]
756 pub fn DADiskGetOptions(disk: &DADisk) -> DADiskOptions;
757}
758
759/// Sets the options for the specified disk.
760///
761/// Parameter `disk`: The disk object for which to set the options.
762///
763/// Parameter `options`: The options to set or clear.
764///
765/// Parameter `value`: Pass TRUE to set options; otherwise pass FALSE to clear options.
766///
767/// Returns: A result code.
768#[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "libc"))]
769#[inline]
770pub unsafe extern "C-unwind" fn DADiskSetOptions(
771 disk: &DADisk,
772 options: DADiskOptions,
773 value: bool,
774) -> DAReturn {
775 extern "C-unwind" {
776 fn DADiskSetOptions(disk: &DADisk, options: DADiskOptions, value: Boolean) -> DAReturn;
777 }
778 unsafe { DADiskSetOptions(disk, options, value as _) }
779}
780
781extern "C-unwind" {
782 /// Unregisters a registered callback function.
783 ///
784 /// Parameter `session`: The session object.
785 ///
786 /// Parameter `callback`: The registered callback function.
787 ///
788 /// Parameter `context`: The user-defined context parameter.
789 #[cfg(feature = "DASession")]
790 pub fn DAUnregisterCallback(
791 session: &DASession,
792 callback: NonNull<c_void>,
793 context: *mut c_void,
794 );
795}
796
797extern "C-unwind" {
798 #[cfg(feature = "DASession")]
799 pub fn DAUnregisterApprovalCallback(
800 session: &DASession,
801 callback: NonNull<c_void>,
802 context: *mut c_void,
803 );
804}