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::invalid_html_tags)]
19
20#[link(name = "DiskArbitration", kind = "framework")]
21extern "C" {}
22
23#[cfg(feature = "DADisk")]
24#[path = "DADisk.rs"]
25mod __DADisk;
26#[cfg(feature = "DADissenter")]
27#[path = "DADissenter.rs"]
28mod __DADissenter;
29#[cfg(feature = "DASession")]
30#[path = "DASession.rs"]
31mod __DASession;
32
33#[cfg(feature = "DADisk")]
34pub use self::__DADisk::kDADiskDescriptionBusNameKey;
35#[cfg(feature = "DADisk")]
36pub use self::__DADisk::kDADiskDescriptionBusPathKey;
37#[cfg(feature = "DADisk")]
38pub use self::__DADisk::kDADiskDescriptionDeviceGUIDKey;
39#[cfg(feature = "DADisk")]
40pub use self::__DADisk::kDADiskDescriptionDeviceInternalKey;
41#[cfg(feature = "DADisk")]
42pub use self::__DADisk::kDADiskDescriptionDeviceModelKey;
43#[cfg(feature = "DADisk")]
44pub use self::__DADisk::kDADiskDescriptionDevicePathKey;
45#[cfg(feature = "DADisk")]
46pub use self::__DADisk::kDADiskDescriptionDeviceProtocolKey;
47#[cfg(feature = "DADisk")]
48pub use self::__DADisk::kDADiskDescriptionDeviceRevisionKey;
49#[cfg(feature = "DADisk")]
50pub use self::__DADisk::kDADiskDescriptionDeviceTDMLockedKey;
51#[cfg(feature = "DADisk")]
52pub use self::__DADisk::kDADiskDescriptionDeviceUnitKey;
53#[cfg(feature = "DADisk")]
54pub use self::__DADisk::kDADiskDescriptionDeviceVendorKey;
55#[cfg(feature = "DADisk")]
56pub use self::__DADisk::kDADiskDescriptionFSKitPrefix;
57#[cfg(feature = "DADisk")]
58pub use self::__DADisk::kDADiskDescriptionMediaBSDMajorKey;
59#[cfg(feature = "DADisk")]
60pub use self::__DADisk::kDADiskDescriptionMediaBSDMinorKey;
61#[cfg(feature = "DADisk")]
62pub use self::__DADisk::kDADiskDescriptionMediaBSDNameKey;
63#[cfg(feature = "DADisk")]
64pub use self::__DADisk::kDADiskDescriptionMediaBSDUnitKey;
65#[cfg(feature = "DADisk")]
66pub use self::__DADisk::kDADiskDescriptionMediaBlockSizeKey;
67#[cfg(feature = "DADisk")]
68pub use self::__DADisk::kDADiskDescriptionMediaContentKey;
69#[cfg(feature = "DADisk")]
70pub use self::__DADisk::kDADiskDescriptionMediaEjectableKey;
71#[cfg(feature = "DADisk")]
72pub use self::__DADisk::kDADiskDescriptionMediaEncryptedKey;
73#[cfg(feature = "DADisk")]
74pub use self::__DADisk::kDADiskDescriptionMediaEncryptionDetailKey;
75#[cfg(feature = "DADisk")]
76pub use self::__DADisk::kDADiskDescriptionMediaIconKey;
77#[cfg(feature = "DADisk")]
78pub use self::__DADisk::kDADiskDescriptionMediaKindKey;
79#[cfg(feature = "DADisk")]
80pub use self::__DADisk::kDADiskDescriptionMediaLeafKey;
81#[cfg(feature = "DADisk")]
82pub use self::__DADisk::kDADiskDescriptionMediaNameKey;
83#[cfg(feature = "DADisk")]
84pub use self::__DADisk::kDADiskDescriptionMediaPathKey;
85#[cfg(feature = "DADisk")]
86pub use self::__DADisk::kDADiskDescriptionMediaRemovableKey;
87#[cfg(feature = "DADisk")]
88pub use self::__DADisk::kDADiskDescriptionMediaSizeKey;
89#[cfg(feature = "DADisk")]
90pub use self::__DADisk::kDADiskDescriptionMediaTypeKey;
91#[cfg(feature = "DADisk")]
92pub use self::__DADisk::kDADiskDescriptionMediaUUIDKey;
93#[cfg(feature = "DADisk")]
94pub use self::__DADisk::kDADiskDescriptionMediaWholeKey;
95#[cfg(feature = "DADisk")]
96pub use self::__DADisk::kDADiskDescriptionMediaWritableKey;
97#[cfg(feature = "DADisk")]
98pub use self::__DADisk::kDADiskDescriptionRepairRunningKey;
99#[cfg(feature = "DADisk")]
100pub use self::__DADisk::kDADiskDescriptionVolumeKindKey;
101#[cfg(feature = "DADisk")]
102pub use self::__DADisk::kDADiskDescriptionVolumeMountableKey;
103#[cfg(feature = "DADisk")]
104pub use self::__DADisk::kDADiskDescriptionVolumeNameKey;
105#[cfg(feature = "DADisk")]
106pub use self::__DADisk::kDADiskDescriptionVolumeNetworkKey;
107#[cfg(feature = "DADisk")]
108pub use self::__DADisk::kDADiskDescriptionVolumePathKey;
109#[cfg(feature = "DADisk")]
110pub use self::__DADisk::kDADiskDescriptionVolumeTypeKey;
111#[cfg(feature = "DADisk")]
112pub use self::__DADisk::kDADiskDescriptionVolumeUUIDKey;
113#[cfg(feature = "DADisk")]
114pub use self::__DADisk::DADisk;
115#[cfg(feature = "DADisk")]
116pub use self::__DADisk::DADiskCopyDescription;
117#[cfg(feature = "DADisk")]
118pub use self::__DADisk::DADiskCopyWholeDisk;
119#[cfg(all(feature = "DADisk", feature = "DASession"))]
120pub use self::__DADisk::DADiskCreateFromBSDName;
121#[cfg(all(feature = "DADisk", feature = "DASession"))]
122pub use self::__DADisk::DADiskCreateFromVolumePath;
123#[cfg(feature = "DADisk")]
124pub use self::__DADisk::DADiskGetBSDName;
125#[cfg(feature = "DADissenter")]
126pub use self::__DADissenter::kDAReturnBadArgument;
127#[cfg(feature = "DADissenter")]
128pub use self::__DADissenter::kDAReturnBusy;
129#[cfg(feature = "DADissenter")]
130pub use self::__DADissenter::kDAReturnError;
131#[cfg(feature = "DADissenter")]
132pub use self::__DADissenter::kDAReturnExclusiveAccess;
133#[cfg(feature = "DADissenter")]
134pub use self::__DADissenter::kDAReturnNoResources;
135#[cfg(feature = "DADissenter")]
136pub use self::__DADissenter::kDAReturnNotFound;
137#[cfg(feature = "DADissenter")]
138pub use self::__DADissenter::kDAReturnNotMounted;
139#[cfg(feature = "DADissenter")]
140pub use self::__DADissenter::kDAReturnNotPermitted;
141#[cfg(feature = "DADissenter")]
142pub use self::__DADissenter::kDAReturnNotPrivileged;
143#[cfg(feature = "DADissenter")]
144pub use self::__DADissenter::kDAReturnNotReady;
145#[cfg(feature = "DADissenter")]
146pub use self::__DADissenter::kDAReturnNotWritable;
147#[cfg(feature = "DADissenter")]
148pub use self::__DADissenter::kDAReturnSuccess;
149#[cfg(feature = "DADissenter")]
150pub use self::__DADissenter::kDAReturnUnsupported;
151#[cfg(feature = "DADissenter")]
152pub use self::__DADissenter::DADissenter;
153#[cfg(all(feature = "DADissenter", feature = "libc"))]
154pub use self::__DADissenter::DADissenterCreate;
155#[cfg(all(feature = "DADissenter", feature = "libc"))]
156pub use self::__DADissenter::DADissenterGetStatus;
157#[cfg(feature = "DADissenter")]
158pub use self::__DADissenter::DADissenterGetStatusString;
159#[cfg(all(feature = "DADissenter", feature = "libc"))]
160pub use self::__DADissenter::DAReturn;
161#[cfg(feature = "DASession")]
162pub use self::__DASession::DAApprovalSession;
163#[cfg(feature = "DASession")]
164pub use self::__DASession::DAApprovalSessionCreate;
165#[cfg(feature = "DASession")]
166pub use self::__DASession::DAApprovalSessionScheduleWithRunLoop;
167#[cfg(feature = "DASession")]
168pub use self::__DASession::DAApprovalSessionUnscheduleFromRunLoop;
169#[cfg(feature = "DASession")]
170pub use self::__DASession::DASession;
171#[cfg(feature = "DASession")]
172pub use self::__DASession::DASessionCreate;
173#[cfg(feature = "DASession")]
174pub use self::__DASession::DASessionScheduleWithRunLoop;
175#[cfg(all(feature = "DASession", feature = "dispatch2"))]
176pub use self::__DASession::DASessionSetDispatchQueue;
177#[cfg(feature = "DASession")]
178pub use self::__DASession::DASessionUnscheduleFromRunLoop;
179use core::ffi::*;
180use core::ptr::NonNull;
181use objc2_core_foundation::*;
182
183use crate::*;
184
185/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskmountoptiondefault?language=objc)
186pub const kDADiskMountOptionDefault: c_uint = 0x00000000;
187/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskmountoptionwhole?language=objc)
188pub const kDADiskMountOptionWhole: c_uint = 0x00000001;
189/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskmountoptionnofollow?language=objc)
190pub const kDADiskMountOptionNoFollow: c_uint = 0x00000002;
191
192/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskmountoptions?language=objc)
193pub type DADiskMountOptions = u32;
194
195/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskrenameoptiondefault?language=objc)
196pub const kDADiskRenameOptionDefault: c_uint = 0x00000000;
197
198/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskrenameoptions?language=objc)
199pub type DADiskRenameOptions = u32;
200
201/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskunmountoptiondefault?language=objc)
202pub const kDADiskUnmountOptionDefault: c_uint = 0x00000000;
203/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskunmountoptionforce?language=objc)
204pub const kDADiskUnmountOptionForce: c_uint = 0x00080000;
205/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskunmountoptionwhole?language=objc)
206pub const kDADiskUnmountOptionWhole: c_uint = 0x00000001;
207
208/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskunmountoptions?language=objc)
209pub type DADiskUnmountOptions = u32;
210
211/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskejectoptiondefault?language=objc)
212pub const kDADiskEjectOptionDefault: c_uint = 0x00000000;
213
214/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskejectoptions?language=objc)
215pub type DADiskEjectOptions = u32;
216
217/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskclaimoptiondefault?language=objc)
218pub const kDADiskClaimOptionDefault: c_uint = 0x00000000;
219
220/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskclaimoptions?language=objc)
221pub type DADiskClaimOptions = u32;
222
223/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskoptiondefault?language=objc)
224pub const kDADiskOptionDefault: c_uint = 0x00000000;
225
226/// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskoptions?language=objc)
227pub type DADiskOptions = u32;
228
229extern "C" {
230 /// Predefined CFDictionary object containing a set of disk description keys and values
231 /// appropriate for matching unformatted media using DARegister*Callback().
232 ///
233 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchmediaunformatted?language=objc)
234 pub static kDADiskDescriptionMatchMediaUnformatted: &'static CFDictionary;
235}
236
237extern "C" {
238 /// Predefined CFDictionary object containing a set of disk description keys and values
239 /// appropriate for matching whole media using DARegister*Callback().
240 ///
241 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchmediawhole?language=objc)
242 pub static kDADiskDescriptionMatchMediaWhole: &'static CFDictionary;
243}
244
245extern "C" {
246 /// Predefined CFDictionary object containing a set of disk description keys and values
247 /// appropriate for matching mountable volumes using DARegister*Callback().
248 ///
249 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchvolumemountable?language=objc)
250 pub static kDADiskDescriptionMatchVolumeMountable: &'static CFDictionary;
251}
252
253extern "C" {
254 /// Predefined CFDictionary object containing a set of disk description keys and values
255 /// appropriate for matching unrecognized volumes using DARegister*Callback().
256 ///
257 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmatchvolumeunrecognized?language=objc)
258 pub static kDADiskDescriptionMatchVolumeUnrecognized: &'static CFDictionary;
259}
260
261extern "C" {
262 /// Predefined CFArray object containing a set of disk description keys appropriate for
263 /// watching volume name changes using DARegisterDiskDescriptionChangedCallback().
264 ///
265 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionwatchvolumename?language=objc)
266 pub static kDADiskDescriptionWatchVolumeName: &'static CFArray;
267}
268
269extern "C" {
270 /// Predefined CFArray object containing a set of disk description keys appropriate for
271 /// watching volume mount changes using DARegisterDiskDescriptionChangedCallback().
272 ///
273 /// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionwatchvolumepath?language=objc)
274 pub static kDADiskDescriptionWatchVolumePath: &'static CFArray;
275}
276
277/// Type of the callback function used by DARegisterDiskAppearedCallback().
278///
279/// Parameter `disk`: A disk object.
280///
281/// Parameter `context`: The user-defined context parameter given to the registration function.
282///
283/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskappearedcallback?language=objc)
284#[cfg(feature = "DADisk")]
285pub type DADiskAppearedCallback = Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void)>;
286
287extern "C-unwind" {
288 /// Registers a callback function to be called whenever a disk has appeared.
289 ///
290 /// Parameter `session`: The session object.
291 ///
292 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
293 ///
294 /// Parameter `callback`: The callback function to call when a disk has appeared.
295 ///
296 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
297 ///
298 /// # Safety
299 ///
300 /// - `match` generics must be of the correct type.
301 /// - `callback` must be implemented correctly.
302 /// - `context` must be a valid pointer or null.
303 #[cfg(all(feature = "DADisk", feature = "DASession"))]
304 pub fn DARegisterDiskAppearedCallback(
305 session: &DASession,
306 r#match: Option<&CFDictionary>,
307 callback: DADiskAppearedCallback,
308 context: *mut c_void,
309 );
310}
311
312/// Type of the callback function used by DARegisterDiskDescriptionChangedCallback().
313///
314/// Parameter `disk`: A disk object.
315///
316/// Parameter `keys`: A list of changed keys.
317///
318/// Parameter `context`: The user-defined context parameter given to the registration function.
319///
320/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskdescriptionchangedcallback?language=objc)
321#[cfg(feature = "DADisk")]
322pub type DADiskDescriptionChangedCallback =
323 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, NonNull<CFArray>, *mut c_void)>;
324
325extern "C-unwind" {
326 /// Registers a callback function to be called whenever a disk description has changed.
327 ///
328 /// Parameter `session`: The session object.
329 ///
330 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
331 ///
332 /// Parameter `watch`: The disk description keys to watch. Pass NULL for all keys.
333 ///
334 /// Parameter `callback`: The callback function to call when a watched key changes.
335 ///
336 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
337 ///
338 /// # Safety
339 ///
340 /// - `match` generics must be of the correct type.
341 /// - `watch` generic must be of the correct type.
342 /// - `callback` must be implemented correctly.
343 /// - `context` must be a valid pointer or null.
344 #[cfg(all(feature = "DADisk", feature = "DASession"))]
345 pub fn DARegisterDiskDescriptionChangedCallback(
346 session: &DASession,
347 r#match: Option<&CFDictionary>,
348 watch: Option<&CFArray>,
349 callback: DADiskDescriptionChangedCallback,
350 context: *mut c_void,
351 );
352}
353
354/// Type of the callback function used by DARegisterDiskDisappearedCallback().
355///
356/// Parameter `disk`: A disk object.
357///
358/// Parameter `context`: The user-defined context parameter given to the registration function.
359///
360/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskdisappearedcallback?language=objc)
361#[cfg(feature = "DADisk")]
362pub type DADiskDisappearedCallback =
363 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void)>;
364
365extern "C-unwind" {
366 /// Registers a callback function to be called whenever a disk has disappeared.
367 ///
368 /// Parameter `session`: The session object.
369 ///
370 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
371 ///
372 /// Parameter `callback`: The callback function to call when a disk has disappeared.
373 ///
374 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
375 ///
376 /// # Safety
377 ///
378 /// - `match` generics must be of the correct type.
379 /// - `callback` must be implemented correctly.
380 /// - `context` must be a valid pointer or null.
381 #[cfg(all(feature = "DADisk", feature = "DASession"))]
382 pub fn DARegisterDiskDisappearedCallback(
383 session: &DASession,
384 r#match: Option<&CFDictionary>,
385 callback: DADiskDisappearedCallback,
386 context: *mut c_void,
387 );
388}
389
390/// Type of the callback function used by DADiskMount().
391///
392/// Parameter `disk`: The disk object.
393///
394/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
395///
396/// Parameter `context`: The user-defined context parameter given to the mount function.
397///
398/// If the disk is already mounted, then status code in the dissenter object will be set to kDAReturnBusy
399///
400/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskmountcallback?language=objc)
401#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
402pub type DADiskMountCallback =
403 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
404
405#[cfg(feature = "DADisk")]
406impl DADisk {
407 /// Mounts the volume at the specified disk object.
408 ///
409 /// Parameter `disk`: The disk object.
410 ///
411 /// Parameter `path`: The mount path. Pass NULL for a "standard" mount path.
412 ///
413 /// Parameter `options`: The mount options.
414 ///
415 /// Parameter `callback`: The callback function to call once the mount completes.
416 ///
417 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
418 ///
419 /// # Safety
420 ///
421 /// - `callback` must be implemented correctly.
422 /// - `context` must be a valid pointer or null.
423 #[doc(alias = "DADiskMount")]
424 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
425 #[inline]
426 pub unsafe fn mount(
427 &self,
428 path: Option<&CFURL>,
429 options: DADiskMountOptions,
430 callback: DADiskMountCallback,
431 context: *mut c_void,
432 ) {
433 extern "C-unwind" {
434 fn DADiskMount(
435 disk: &DADisk,
436 path: Option<&CFURL>,
437 options: DADiskMountOptions,
438 callback: DADiskMountCallback,
439 context: *mut c_void,
440 );
441 }
442 unsafe { DADiskMount(self, path, options, callback, context) }
443 }
444
445 /// Mounts the volume at the specified disk object, with the specified mount options.
446 ///
447 /// Parameter `disk`: The disk object.
448 ///
449 /// Parameter `path`: The mount path. Pass NULL for a "standard" mount path.
450 ///
451 /// Parameter `options`: The mount options.
452 ///
453 /// Parameter `callback`: The callback function to call once the mount completes.
454 ///
455 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
456 ///
457 /// Parameter `arguments`: The null-terminated list of mount options to pass to /sbin/mount -o.
458 ///
459 /// # Safety
460 ///
461 /// - `callback` must be implemented correctly.
462 /// - `context` must be a valid pointer or null.
463 /// - `arguments` must be a valid pointer or null.
464 #[doc(alias = "DADiskMountWithArguments")]
465 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
466 #[inline]
467 pub unsafe fn mount_with_arguments(
468 &self,
469 path: Option<&CFURL>,
470 options: DADiskMountOptions,
471 callback: DADiskMountCallback,
472 context: *mut c_void,
473 arguments: *mut *const CFString,
474 ) {
475 extern "C-unwind" {
476 fn DADiskMountWithArguments(
477 disk: &DADisk,
478 path: Option<&CFURL>,
479 options: DADiskMountOptions,
480 callback: DADiskMountCallback,
481 context: *mut c_void,
482 arguments: *mut *const CFString,
483 );
484 }
485 unsafe { DADiskMountWithArguments(self, path, options, callback, context, arguments) }
486 }
487}
488
489/// Type of the callback function used by DARegisterDiskMountApprovalCallback().
490///
491/// Parameter `disk`: A disk object.
492///
493/// Parameter `context`: The user-defined context parameter given to the registration function.
494///
495/// Returns: A dissenter reference. Pass NULL to approve.
496///
497/// The caller of this callback receives a reference to the returned object. The
498/// caller also implicitly retains the object and is responsible for releasing it
499/// with CFRelease().
500///
501/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskmountapprovalcallback?language=objc)
502#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
503pub type DADiskMountApprovalCallback =
504 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
505
506extern "C-unwind" {
507 /// Registers a callback function to be called whenever a volume is to be mounted.
508 ///
509 /// Parameter `session`: The session object.
510 ///
511 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
512 ///
513 /// Parameter `callback`: The callback function to call when a volume is to be mounted.
514 ///
515 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
516 ///
517 /// # Safety
518 ///
519 /// - `match` generics must be of the correct type.
520 /// - `callback` must be implemented correctly.
521 /// - `context` must be a valid pointer or null.
522 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "DASession"))]
523 pub fn DARegisterDiskMountApprovalCallback(
524 session: &DASession,
525 r#match: Option<&CFDictionary>,
526 callback: DADiskMountApprovalCallback,
527 context: *mut c_void,
528 );
529}
530
531/// Type of the callback function used by DADiskRename().
532///
533/// Parameter `disk`: The disk object.
534///
535/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
536///
537/// Parameter `context`: The user-defined context parameter given to the rename function.
538///
539/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskrenamecallback?language=objc)
540#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
541pub type DADiskRenameCallback =
542 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
543
544#[cfg(feature = "DADisk")]
545impl DADisk {
546 /// Renames the volume at the specified disk object.
547 ///
548 /// Parameter `disk`: The disk object.
549 ///
550 /// Parameter `options`: The rename options.
551 ///
552 /// Parameter `callback`: The callback function to call once the rename completes.
553 ///
554 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
555 ///
556 /// # Safety
557 ///
558 /// - `callback` must be implemented correctly.
559 /// - `context` must be a valid pointer or null.
560 #[doc(alias = "DADiskRename")]
561 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
562 #[inline]
563 pub unsafe fn rename(
564 &self,
565 name: &CFString,
566 options: DADiskRenameOptions,
567 callback: DADiskRenameCallback,
568 context: *mut c_void,
569 ) {
570 extern "C-unwind" {
571 fn DADiskRename(
572 disk: &DADisk,
573 name: &CFString,
574 options: DADiskRenameOptions,
575 callback: DADiskRenameCallback,
576 context: *mut c_void,
577 );
578 }
579 unsafe { DADiskRename(self, name, options, callback, context) }
580 }
581}
582
583/// Type of the callback function used by DADiskUnmount().
584///
585/// Parameter `disk`: The disk object.
586///
587/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
588///
589/// Parameter `context`: The user-defined context parameter given to the unmount function.
590///
591/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskunmountcallback?language=objc)
592#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
593pub type DADiskUnmountCallback =
594 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
595
596#[cfg(feature = "DADisk")]
597impl DADisk {
598 /// Unmounts the volume at the specified disk object.
599 ///
600 /// Parameter `disk`: The disk object.
601 ///
602 /// Parameter `options`: The unmount options.
603 ///
604 /// Parameter `callback`: The callback function to call once the unmount completes.
605 ///
606 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
607 ///
608 /// # Safety
609 ///
610 /// - `callback` must be implemented correctly.
611 /// - `context` must be a valid pointer or null.
612 #[doc(alias = "DADiskUnmount")]
613 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
614 #[inline]
615 pub unsafe fn unmount(
616 &self,
617 options: DADiskUnmountOptions,
618 callback: DADiskUnmountCallback,
619 context: *mut c_void,
620 ) {
621 extern "C-unwind" {
622 fn DADiskUnmount(
623 disk: &DADisk,
624 options: DADiskUnmountOptions,
625 callback: DADiskUnmountCallback,
626 context: *mut c_void,
627 );
628 }
629 unsafe { DADiskUnmount(self, options, callback, context) }
630 }
631}
632
633/// Type of the callback function used by DARegisterDiskUnmountApprovalCallback().
634///
635/// Parameter `disk`: A disk object.
636///
637/// Parameter `context`: The user-defined context parameter given to the registration function.
638///
639/// Returns: A dissenter reference. Pass NULL to approve.
640///
641/// The caller of this callback receives a reference to the returned object. The
642/// caller also implicitly retains the object and is responsible for releasing it
643/// with CFRelease().
644///
645/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskunmountapprovalcallback?language=objc)
646#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
647pub type DADiskUnmountApprovalCallback =
648 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
649
650extern "C-unwind" {
651 /// Registers a callback function to be called whenever a volume is to be unmounted.
652 ///
653 /// Parameter `session`: The session object.
654 ///
655 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
656 ///
657 /// Parameter `callback`: The callback function to call when a volume is to be unmounted.
658 ///
659 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
660 ///
661 /// # Safety
662 ///
663 /// - `match` generics must be of the correct type.
664 /// - `callback` must be implemented correctly.
665 /// - `context` must be a valid pointer or null.
666 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "DASession"))]
667 pub fn DARegisterDiskUnmountApprovalCallback(
668 session: &DASession,
669 r#match: Option<&CFDictionary>,
670 callback: DADiskUnmountApprovalCallback,
671 context: *mut c_void,
672 );
673}
674
675/// Type of the callback function used by DADiskEject().
676///
677/// Parameter `disk`: The disk object.
678///
679/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
680///
681/// Parameter `context`: The user-defined context parameter given to the eject function.
682///
683/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskejectcallback?language=objc)
684#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
685pub type DADiskEjectCallback =
686 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
687
688#[cfg(feature = "DADisk")]
689impl DADisk {
690 /// Ejects the specified disk object.
691 ///
692 /// Parameter `disk`: The disk object.
693 ///
694 /// Parameter `options`: The eject options.
695 ///
696 /// Parameter `callback`: The callback function to call once the ejection completes.
697 ///
698 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
699 ///
700 /// # Safety
701 ///
702 /// - `callback` must be implemented correctly.
703 /// - `context` must be a valid pointer or null.
704 #[doc(alias = "DADiskEject")]
705 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
706 #[inline]
707 pub unsafe fn eject(
708 &self,
709 options: DADiskEjectOptions,
710 callback: DADiskEjectCallback,
711 context: *mut c_void,
712 ) {
713 extern "C-unwind" {
714 fn DADiskEject(
715 disk: &DADisk,
716 options: DADiskEjectOptions,
717 callback: DADiskEjectCallback,
718 context: *mut c_void,
719 );
720 }
721 unsafe { DADiskEject(self, options, callback, context) }
722 }
723}
724
725/// Type of the callback function used by DARegisterDiskEjectApprovalCallback().
726///
727/// Parameter `disk`: A disk object.
728///
729/// Parameter `context`: The user-defined context parameter given to the registration function.
730///
731/// Returns: A dissenter reference. Pass NULL to approve.
732///
733/// The caller of this callback receives a reference to the returned object. The
734/// caller also implicitly retains the object and is responsible for releasing it
735/// with CFRelease().
736///
737/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskejectapprovalcallback?language=objc)
738#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
739pub type DADiskEjectApprovalCallback =
740 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
741
742extern "C-unwind" {
743 /// Registers a callback function to be called whenever a volume is to be ejected.
744 ///
745 /// Parameter `session`: The session object.
746 ///
747 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
748 ///
749 /// Parameter `callback`: The callback function to call when a volume is to be ejected.
750 ///
751 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
752 ///
753 /// # Safety
754 ///
755 /// - `match` generics must be of the correct type.
756 /// - `callback` must be implemented correctly.
757 /// - `context` must be a valid pointer or null.
758 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "DASession"))]
759 pub fn DARegisterDiskEjectApprovalCallback(
760 session: &DASession,
761 r#match: Option<&CFDictionary>,
762 callback: DADiskEjectApprovalCallback,
763 context: *mut c_void,
764 );
765}
766
767/// Type of the callback function used by DADiskClaim().
768///
769/// Parameter `disk`: The disk object.
770///
771/// Parameter `dissenter`: A dissenter object on failure or NULL on success.
772///
773/// Parameter `context`: The user-defined context parameter given to the claim function.
774///
775/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskclaimcallback?language=objc)
776#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
777pub type DADiskClaimCallback =
778 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *const DADissenter, *mut c_void)>;
779
780/// Type of the callback function used by DADiskClaim().
781///
782/// Parameter `disk`: The disk object.
783///
784/// Parameter `context`: The user-defined context parameter given to the claim function.
785///
786/// Returns: A dissenter reference. Pass NULL to release claim.
787///
788/// The caller of this callback receives a reference to the returned object. The
789/// caller also implicitly retains the object and is responsible for releasing it
790/// with CFRelease().
791///
792/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskclaimreleasecallback?language=objc)
793#[cfg(all(feature = "DADisk", feature = "DADissenter"))]
794pub type DADiskClaimReleaseCallback =
795 Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void) -> *const DADissenter>;
796
797#[cfg(feature = "DADisk")]
798impl DADisk {
799 /// Claims the specified disk object for exclusive use.
800 ///
801 /// Parameter `disk`: The disk object.
802 ///
803 /// Parameter `options`: The claim options.
804 ///
805 /// Parameter `release`: The callback function to call when the claim is to be released.
806 ///
807 /// Parameter `releaseContext`: The user-defined context parameter to pass to the callback function.
808 ///
809 /// Parameter `callback`: The callback function to call once the claim completes.
810 ///
811 /// Parameter `callbackContext`: The user-defined context parameter to pass to the callback function.
812 ///
813 /// # Safety
814 ///
815 /// - `release` must be implemented correctly.
816 /// - `release_context` must be a valid pointer or null.
817 /// - `callback` must be implemented correctly.
818 /// - `callback_context` must be a valid pointer or null.
819 #[doc(alias = "DADiskClaim")]
820 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
821 #[inline]
822 pub unsafe fn claim(
823 &self,
824 options: DADiskClaimOptions,
825 release: DADiskClaimReleaseCallback,
826 release_context: *mut c_void,
827 callback: DADiskClaimCallback,
828 callback_context: *mut c_void,
829 ) {
830 extern "C-unwind" {
831 fn DADiskClaim(
832 disk: &DADisk,
833 options: DADiskClaimOptions,
834 release: DADiskClaimReleaseCallback,
835 release_context: *mut c_void,
836 callback: DADiskClaimCallback,
837 callback_context: *mut c_void,
838 );
839 }
840 unsafe {
841 DADiskClaim(
842 self,
843 options,
844 release,
845 release_context,
846 callback,
847 callback_context,
848 )
849 }
850 }
851
852 /// Reports whether or not the disk is claimed.
853 ///
854 /// Parameter `disk`: The disk object.
855 ///
856 /// Returns: TRUE if the disk is claimed, otherwise FALSE.
857 #[doc(alias = "DADiskIsClaimed")]
858 #[cfg(feature = "DADisk")]
859 #[inline]
860 pub unsafe fn is_claimed(&self) -> bool {
861 extern "C-unwind" {
862 fn DADiskIsClaimed(disk: &DADisk) -> Boolean;
863 }
864 let ret = unsafe { DADiskIsClaimed(self) };
865 ret != 0
866 }
867
868 /// Unclaims the specified disk object.
869 ///
870 /// Parameter `disk`: The disk object.
871 #[doc(alias = "DADiskUnclaim")]
872 #[cfg(feature = "DADisk")]
873 #[inline]
874 pub unsafe fn unclaim(&self) {
875 extern "C-unwind" {
876 fn DADiskUnclaim(disk: &DADisk);
877 }
878 unsafe { DADiskUnclaim(self) }
879 }
880}
881
882/// Type of the callback function used by DARegisterDiskPeekCallback().
883///
884/// Parameter `disk`: A disk object.
885///
886/// Parameter `context`: The user-defined context parameter given to the registration function.
887///
888/// The peek callback functions are called in a specific order, from lowest order to highest
889/// order. DADiskClaim() could be used here to claim the disk object and DADiskSetOptions()
890/// could be used here to set up options on the disk object.
891///
892/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadiskpeekcallback?language=objc)
893#[cfg(feature = "DADisk")]
894pub type DADiskPeekCallback = Option<unsafe extern "C-unwind" fn(NonNull<DADisk>, *mut c_void)>;
895
896extern "C-unwind" {
897 /// Registers a callback function to be called whenever a disk has been probed.
898 ///
899 /// Parameter `session`: The session object.
900 ///
901 /// Parameter `match`: The disk description keys to match. Pass NULL for all disk objects.
902 ///
903 /// Parameter `order`: The callback order, from lowest to highest. Pass 0 for the default.
904 ///
905 /// Parameter `callback`: The callback function to call when a disk has been probed.
906 ///
907 /// Parameter `context`: The user-defined context parameter to pass to the callback function.
908 ///
909 /// # Safety
910 ///
911 /// - `match` generics must be of the correct type.
912 /// - `callback` must be implemented correctly.
913 /// - `context` must be a valid pointer or null.
914 #[cfg(all(feature = "DADisk", feature = "DASession"))]
915 pub fn DARegisterDiskPeekCallback(
916 session: &DASession,
917 r#match: Option<&CFDictionary>,
918 order: CFIndex,
919 callback: DADiskPeekCallback,
920 context: *mut c_void,
921 );
922}
923
924#[cfg(feature = "DADisk")]
925impl DADisk {
926 /// Obtains the options for the specified disk.
927 ///
928 /// Parameter `disk`: The disk object for which to obtain the options.
929 ///
930 /// Returns: The options.
931 #[doc(alias = "DADiskGetOptions")]
932 #[cfg(feature = "DADisk")]
933 #[inline]
934 pub unsafe fn options(&self) -> DADiskOptions {
935 extern "C-unwind" {
936 fn DADiskGetOptions(disk: &DADisk) -> DADiskOptions;
937 }
938 unsafe { DADiskGetOptions(self) }
939 }
940
941 /// Sets the options for the specified disk.
942 ///
943 /// Parameter `disk`: The disk object for which to set the options.
944 ///
945 /// Parameter `options`: The options to set or clear.
946 ///
947 /// Parameter `value`: Pass TRUE to set options; otherwise pass FALSE to clear options.
948 ///
949 /// Returns: A result code.
950 #[doc(alias = "DADiskSetOptions")]
951 #[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "libc"))]
952 #[inline]
953 pub unsafe fn set_options(&self, options: DADiskOptions, value: bool) -> DAReturn {
954 extern "C-unwind" {
955 fn DADiskSetOptions(disk: &DADisk, options: DADiskOptions, value: Boolean) -> DAReturn;
956 }
957 unsafe { DADiskSetOptions(self, options, value as _) }
958 }
959}
960
961extern "C-unwind" {
962 /// Unregisters a registered callback function.
963 ///
964 /// Parameter `session`: The session object.
965 ///
966 /// Parameter `callback`: The registered callback function.
967 ///
968 /// Parameter `context`: The user-defined context parameter.
969 ///
970 /// # Safety
971 ///
972 /// - `callback` must be a valid pointer.
973 /// - `context` must be a valid pointer or null.
974 #[cfg(feature = "DASession")]
975 pub fn DAUnregisterCallback(
976 session: &DASession,
977 callback: NonNull<c_void>,
978 context: *mut c_void,
979 );
980}
981
982extern "C-unwind" {
983 /// # Safety
984 ///
985 /// - `callback` must be a valid pointer.
986 /// - `context` must be a valid pointer or null.
987 #[cfg(feature = "DASession")]
988 pub fn DAUnregisterApprovalCallback(
989 session: &DASession,
990 callback: NonNull<c_void>,
991 context: *mut c_void,
992 );
993}
994
995extern "C-unwind" {
996 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
997 #[deprecated = "renamed to `DADisk::mount`"]
998 pub fn DADiskMount(
999 disk: &DADisk,
1000 path: Option<&CFURL>,
1001 options: DADiskMountOptions,
1002 callback: DADiskMountCallback,
1003 context: *mut c_void,
1004 );
1005}
1006
1007extern "C-unwind" {
1008 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
1009 #[deprecated = "renamed to `DADisk::mount_with_arguments`"]
1010 pub fn DADiskMountWithArguments(
1011 disk: &DADisk,
1012 path: Option<&CFURL>,
1013 options: DADiskMountOptions,
1014 callback: DADiskMountCallback,
1015 context: *mut c_void,
1016 arguments: *mut *const CFString,
1017 );
1018}
1019
1020extern "C-unwind" {
1021 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
1022 #[deprecated = "renamed to `DADisk::rename`"]
1023 pub fn DADiskRename(
1024 disk: &DADisk,
1025 name: &CFString,
1026 options: DADiskRenameOptions,
1027 callback: DADiskRenameCallback,
1028 context: *mut c_void,
1029 );
1030}
1031
1032extern "C-unwind" {
1033 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
1034 #[deprecated = "renamed to `DADisk::unmount`"]
1035 pub fn DADiskUnmount(
1036 disk: &DADisk,
1037 options: DADiskUnmountOptions,
1038 callback: DADiskUnmountCallback,
1039 context: *mut c_void,
1040 );
1041}
1042
1043extern "C-unwind" {
1044 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
1045 #[deprecated = "renamed to `DADisk::eject`"]
1046 pub fn DADiskEject(
1047 disk: &DADisk,
1048 options: DADiskEjectOptions,
1049 callback: DADiskEjectCallback,
1050 context: *mut c_void,
1051 );
1052}
1053
1054extern "C-unwind" {
1055 #[cfg(all(feature = "DADisk", feature = "DADissenter"))]
1056 #[deprecated = "renamed to `DADisk::claim`"]
1057 pub fn DADiskClaim(
1058 disk: &DADisk,
1059 options: DADiskClaimOptions,
1060 release: DADiskClaimReleaseCallback,
1061 release_context: *mut c_void,
1062 callback: DADiskClaimCallback,
1063 callback_context: *mut c_void,
1064 );
1065}
1066
1067#[cfg(feature = "DADisk")]
1068#[deprecated = "renamed to `DADisk::is_claimed`"]
1069#[inline]
1070pub unsafe extern "C-unwind" fn DADiskIsClaimed(disk: &DADisk) -> bool {
1071 extern "C-unwind" {
1072 fn DADiskIsClaimed(disk: &DADisk) -> Boolean;
1073 }
1074 let ret = unsafe { DADiskIsClaimed(disk) };
1075 ret != 0
1076}
1077
1078extern "C-unwind" {
1079 #[cfg(feature = "DADisk")]
1080 #[deprecated = "renamed to `DADisk::unclaim`"]
1081 pub fn DADiskUnclaim(disk: &DADisk);
1082}
1083
1084extern "C-unwind" {
1085 #[cfg(feature = "DADisk")]
1086 #[deprecated = "renamed to `DADisk::options`"]
1087 pub fn DADiskGetOptions(disk: &DADisk) -> DADiskOptions;
1088}
1089
1090#[cfg(all(feature = "DADisk", feature = "DADissenter", feature = "libc"))]
1091#[deprecated = "renamed to `DADisk::set_options`"]
1092#[inline]
1093pub unsafe extern "C-unwind" fn DADiskSetOptions(
1094 disk: &DADisk,
1095 options: DADiskOptions,
1096 value: bool,
1097) -> DAReturn {
1098 extern "C-unwind" {
1099 fn DADiskSetOptions(disk: &DADisk, options: DADiskOptions, value: Boolean) -> DAReturn;
1100 }
1101 unsafe { DADiskSetOptions(disk, options, value as _) }
1102}