disk_arbitration_sys/callbacks.rs
1use crate::prelude::*;
2
3/// Type of the callback function used by [`DARegisterDiskAppearedCallback`].
4///
5/// # Parameters
6///
7/// * `disk` - A disk object.
8/// * `context` - The user-defined context parameter given to the registration function.
9pub type DADiskAppearedCallback =
10 Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void)>;
11
12/// Type of the callback function used by [`DARegisterDiskDescriptionChangedCallback`].
13///
14/// # Parameters
15///
16/// * `disk` - A disk object.
17/// * `keys` - A list of changed keys.
18/// * `context` - The user-defined context parameter given to the registration function.
19pub type DADiskDescriptionChangedCallback =
20 Option<unsafe extern "C" fn(disk: DADiskRef, keys: CFArrayRef, context: *mut c_void)>;
21
22/// Type of the callback function used by [`DARegisterDiskDisappearedCallback`].
23///
24/// # Parameters
25///
26/// * `disk` - A disk object.
27/// * `context` - The user-defined context parameter given to the registration function.
28pub type DADiskDisappearedCallback =
29 Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void)>;
30
31/// Type of the callback function used by [`DADiskMount`].
32///
33/// # Parameters
34///
35/// * `disk` - The disk object.
36/// * `dissenter` - A dissenter object on failure or NULL on success.
37/// * `context` - The user-defined context parameter given to the mount function.
38///
39/// # Discussion
40///
41/// If the disk is already mounted, then status code in the
42/// dissenter object will be set to [`kDAReturnBusy`].
43pub type DADiskMountCallback =
44 Option<unsafe extern "C" fn(disk: DADiskRef, dissenter: DADissenterRef, context: *mut c_void)>;
45
46/// Type of the callback function used by [`DARegisterDiskMountApprovalCallback`].
47///
48/// # Parameters
49///
50/// * `disk` - A disk object.
51/// * `context` - The user-defined context parameter given to the registration function.
52///
53/// # Returns
54///
55/// A dissenter reference. Pass NULL to approve.
56///
57/// # Discussion
58///
59/// The caller of this callback receives a reference to the returned object. The
60/// caller also implicitly retains the object and is responsible for releasing it
61/// with [`CFRelease`].
62pub type DADiskMountApprovalCallback =
63 Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void) -> DADissenterRef>;
64
65/// Type of the callback function used by [`DADiskRename`].
66///
67/// # Parameters
68///
69/// * `disk` - The disk object.
70/// * `dissenter` - A dissenter object on failure or NULL on success.
71/// * `context` - The user-defined context parameter given to the rename function.
72pub type DADiskRenameCallback =
73 Option<unsafe extern "C" fn(disk: DADiskRef, dissenter: DADissenterRef, context: *mut c_void)>;
74
75/// Type of the callback function used by [`DADiskUnmount`].
76///
77/// # Parameters
78///
79/// * `disk` - The disk object.
80/// * `dissenter` - A dissenter object on failure or NULL on success.
81/// * `context` - The user-defined context parameter given to the unmount function.
82pub type DADiskUnmountCallback =
83 Option<unsafe extern "C" fn(disk: DADiskRef, dissenter: DADissenterRef, context: *mut c_void)>;
84
85/// Type of the callback function used by [`DARegisterDiskUnmountApprovalCallback`].
86///
87/// # Parameters
88///
89/// * `disk` - A disk object.
90/// * `context` - The user-defined context parameter given to the registration function.
91///
92/// # Returns
93///
94/// A dissenter reference. Pass NULL to approve.
95///
96/// # Discussion
97///
98/// The caller of this callback receives a reference to the returned object. The
99/// caller also implicitly retains the object and is responsible for releasing it
100/// with [`CFRelease`].
101pub type DADiskUnmountApprovalCallback =
102 Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void) -> DADissenterRef>;
103
104/// Type of the callback function used by [`DADiskEject`].
105///
106/// # Parameters
107///
108/// * `disk` - The disk object.
109/// * `dissenter` - A dissenter object on failure or NULL on success.
110/// * `context` - The user-defined context parameter given to the eject function."#]
111pub type DADiskEjectCallback =
112 Option<unsafe extern "C" fn(disk: DADiskRef, dissenter: DADissenterRef, context: *mut c_void)>;
113
114/// Type of the callback function used by [`DARegisterDiskEjectApprovalCallback`].
115///
116/// # Parameters
117///
118/// * `disk` - A disk object.
119/// * `context` - The user-defined context parameter given to the registration function.
120///
121/// # Returns
122///
123/// A dissenter reference. Pass NULL to approve.
124///
125/// # Discussion
126///
127/// The caller of this callback receives a reference to the returned object. The
128/// caller also implicitly retains the object and is responsible for releasing it
129/// with [`CFRelease`]
130pub type DADiskEjectApprovalCallback =
131 Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void) -> DADissenterRef>;
132
133/// Type of the callback function used by [`DADiskClaim`].
134///
135/// # Parameters
136///
137/// * `disk` - The disk object.
138/// * `dissenter` - A dissenter object on failure or NULL on success.
139/// * `context` - The user-defined context parameter given to the claim function.
140pub type DADiskClaimCallback =
141 Option<unsafe extern "C" fn(disk: DADiskRef, dissenter: DADissenterRef, context: *mut c_void)>;
142
143/// Type of the callback function used by [`DADiskClaim`].
144///
145/// # Parameters
146///
147/// * `disk` - The disk object.
148/// * `context` - The user-defined context parameter given to the claim function.
149///
150/// # Returns
151///
152/// A dissenter reference. Pass NULL to release claim.
153///
154/// # Discussion
155///
156/// The caller of this callback receives a reference to the returned object. The
157/// caller also implicitly retains the object and is responsible for releasing it
158/// with [`CFRelease`].
159pub type DADiskClaimReleaseCallback =
160 Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void) -> DADissenterRef>;
161
162/// Type of the callback function used by [`DARegisterDiskPeekCallback`].
163///
164/// # Parameters
165///
166/// * `disk` - A disk object.
167/// * `context` - The user-defined context parameter given to the registration function.
168///
169/// # Discussion
170///
171/// The peek callback functions are called in a specific order, from lowest order to highest
172/// order. [`DADiskClaim`] could be used here to claim the disk object and
173/// [`DADiskSetOptions`] could be used here to set up options on the disk object.
174pub type DADiskPeekCallback = Option<unsafe extern "C" fn(disk: DADiskRef, context: *mut c_void)>;