objc2_disk_arbitration/generated/DADisk.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;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13extern "C" {
14 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumekindkey?language=objc)
15 pub static kDADiskDescriptionVolumeKindKey: &'static CFString;
16}
17
18extern "C" {
19 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumemountablekey?language=objc)
20 pub static kDADiskDescriptionVolumeMountableKey: &'static CFString;
21}
22
23extern "C" {
24 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumenamekey?language=objc)
25 pub static kDADiskDescriptionVolumeNameKey: &'static CFString;
26}
27
28extern "C" {
29 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumenetworkkey?language=objc)
30 pub static kDADiskDescriptionVolumeNetworkKey: &'static CFString;
31}
32
33extern "C" {
34 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumepathkey?language=objc)
35 pub static kDADiskDescriptionVolumePathKey: &'static CFString;
36}
37
38extern "C" {
39 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumetypekey?language=objc)
40 pub static kDADiskDescriptionVolumeTypeKey: &'static CFString;
41}
42
43extern "C" {
44 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionvolumeuuidkey?language=objc)
45 pub static kDADiskDescriptionVolumeUUIDKey: &'static CFString;
46}
47
48extern "C" {
49 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediablocksizekey?language=objc)
50 pub static kDADiskDescriptionMediaBlockSizeKey: &'static CFString;
51}
52
53extern "C" {
54 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediabsdmajorkey?language=objc)
55 pub static kDADiskDescriptionMediaBSDMajorKey: &'static CFString;
56}
57
58extern "C" {
59 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediabsdminorkey?language=objc)
60 pub static kDADiskDescriptionMediaBSDMinorKey: &'static CFString;
61}
62
63extern "C" {
64 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediabsdnamekey?language=objc)
65 pub static kDADiskDescriptionMediaBSDNameKey: &'static CFString;
66}
67
68extern "C" {
69 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediabsdunitkey?language=objc)
70 pub static kDADiskDescriptionMediaBSDUnitKey: &'static CFString;
71}
72
73extern "C" {
74 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediacontentkey?language=objc)
75 pub static kDADiskDescriptionMediaContentKey: &'static CFString;
76}
77
78extern "C" {
79 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediaejectablekey?language=objc)
80 pub static kDADiskDescriptionMediaEjectableKey: &'static CFString;
81}
82
83extern "C" {
84 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediaiconkey?language=objc)
85 pub static kDADiskDescriptionMediaIconKey: &'static CFString;
86}
87
88extern "C" {
89 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediakindkey?language=objc)
90 pub static kDADiskDescriptionMediaKindKey: &'static CFString;
91}
92
93extern "C" {
94 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmedialeafkey?language=objc)
95 pub static kDADiskDescriptionMediaLeafKey: &'static CFString;
96}
97
98extern "C" {
99 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmedianamekey?language=objc)
100 pub static kDADiskDescriptionMediaNameKey: &'static CFString;
101}
102
103extern "C" {
104 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediapathkey?language=objc)
105 pub static kDADiskDescriptionMediaPathKey: &'static CFString;
106}
107
108extern "C" {
109 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediaremovablekey?language=objc)
110 pub static kDADiskDescriptionMediaRemovableKey: &'static CFString;
111}
112
113extern "C" {
114 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediasizekey?language=objc)
115 pub static kDADiskDescriptionMediaSizeKey: &'static CFString;
116}
117
118extern "C" {
119 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediatypekey?language=objc)
120 pub static kDADiskDescriptionMediaTypeKey: &'static CFString;
121}
122
123extern "C" {
124 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediauuidkey?language=objc)
125 pub static kDADiskDescriptionMediaUUIDKey: &'static CFString;
126}
127
128extern "C" {
129 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediawholekey?language=objc)
130 pub static kDADiskDescriptionMediaWholeKey: &'static CFString;
131}
132
133extern "C" {
134 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediawritablekey?language=objc)
135 pub static kDADiskDescriptionMediaWritableKey: &'static CFString;
136}
137
138extern "C" {
139 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediaencryptedkey?language=objc)
140 pub static kDADiskDescriptionMediaEncryptedKey: &'static CFString;
141}
142
143extern "C" {
144 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionmediaencryptiondetailkey?language=objc)
145 pub static kDADiskDescriptionMediaEncryptionDetailKey: &'static CFString;
146}
147
148extern "C" {
149 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondeviceguidkey?language=objc)
150 pub static kDADiskDescriptionDeviceGUIDKey: &'static CFString;
151}
152
153extern "C" {
154 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondeviceinternalkey?language=objc)
155 pub static kDADiskDescriptionDeviceInternalKey: &'static CFString;
156}
157
158extern "C" {
159 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondevicemodelkey?language=objc)
160 pub static kDADiskDescriptionDeviceModelKey: &'static CFString;
161}
162
163extern "C" {
164 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondevicepathkey?language=objc)
165 pub static kDADiskDescriptionDevicePathKey: &'static CFString;
166}
167
168extern "C" {
169 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondeviceprotocolkey?language=objc)
170 pub static kDADiskDescriptionDeviceProtocolKey: &'static CFString;
171}
172
173extern "C" {
174 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondevicerevisionkey?language=objc)
175 pub static kDADiskDescriptionDeviceRevisionKey: &'static CFString;
176}
177
178extern "C" {
179 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondeviceunitkey?language=objc)
180 pub static kDADiskDescriptionDeviceUnitKey: &'static CFString;
181}
182
183extern "C" {
184 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondevicevendorkey?language=objc)
185 pub static kDADiskDescriptionDeviceVendorKey: &'static CFString;
186}
187
188extern "C" {
189 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptiondevicetdmlockedkey?language=objc)
190 pub static kDADiskDescriptionDeviceTDMLockedKey: &'static CFString;
191}
192
193extern "C" {
194 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionbusnamekey?language=objc)
195 pub static kDADiskDescriptionBusNameKey: &'static CFString;
196}
197
198extern "C" {
199 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionbuspathkey?language=objc)
200 pub static kDADiskDescriptionBusPathKey: &'static CFString;
201}
202
203extern "C" {
204 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionfskitprefix?language=objc)
205 pub static kDADiskDescriptionFSKitPrefix: &'static CFString;
206}
207
208extern "C" {
209 /// [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/kdadiskdescriptionrepairrunningkey?language=objc)
210 pub static kDADiskDescriptionRepairRunningKey: &'static CFString;
211}
212
213/// Type of a reference to DADisk instances.
214///
215/// See also [Apple's documentation](https://developer.apple.com/documentation/diskarbitration/dadisk?language=objc)
216#[doc(alias = "DADiskRef")]
217#[repr(C)]
218pub struct DADisk {
219 inner: [u8; 0],
220 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
221}
222
223cf_type!(
224 unsafe impl DADisk {}
225);
226#[cfg(feature = "objc2")]
227cf_objc2_type!(
228 unsafe impl RefEncode<"__DADisk"> for DADisk {}
229);
230
231unsafe impl ConcreteType for DADisk {
232 /// Returns the type identifier of all DADisk instances.
233 #[doc(alias = "DADiskGetTypeID")]
234 #[inline]
235 fn type_id() -> CFTypeID {
236 extern "C-unwind" {
237 fn DADiskGetTypeID() -> CFTypeID;
238 }
239 unsafe { DADiskGetTypeID() }
240 }
241}
242
243impl DADisk {
244 /// Creates a new disk object.
245 ///
246 /// Parameter `allocator`: The allocator object to be used to allocate memory.
247 ///
248 /// Parameter `session`: The DASession in which to contact Disk Arbitration.
249 ///
250 /// Parameter `name`: The BSD device name.
251 ///
252 /// Returns: A reference to a new DADisk.
253 ///
254 /// The caller of this function receives a reference to the returned object. The
255 /// caller also implicitly retains the object and is responsible for releasing it
256 /// with CFRelease().
257 ///
258 /// # Safety
259 ///
260 /// `name` must be a valid pointer.
261 #[doc(alias = "DADiskCreateFromBSDName")]
262 #[cfg(feature = "DASession")]
263 #[inline]
264 pub unsafe fn from_bsd_name(
265 allocator: Option<&CFAllocator>,
266 session: &DASession,
267 name: NonNull<c_char>,
268 ) -> Option<CFRetained<DADisk>> {
269 extern "C-unwind" {
270 fn DADiskCreateFromBSDName(
271 allocator: Option<&CFAllocator>,
272 session: &DASession,
273 name: NonNull<c_char>,
274 ) -> Option<NonNull<DADisk>>;
275 }
276 let ret = unsafe { DADiskCreateFromBSDName(allocator, session, name) };
277 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
278 }
279
280 /// Creates a new disk object.
281 ///
282 /// Parameter `allocator`: The allocator object to be used to allocate memory.
283 ///
284 /// Parameter `session`: The DASession in which to contact Disk Arbitration.
285 ///
286 /// Parameter `path`: The BSD mount point.
287 ///
288 /// Returns: A reference to a new DADisk.
289 ///
290 /// The caller of this function receives a reference to the returned object. The
291 /// caller also implicitly retains the object and is responsible for releasing it
292 /// with CFRelease().
293 #[doc(alias = "DADiskCreateFromVolumePath")]
294 #[cfg(feature = "DASession")]
295 #[inline]
296 pub unsafe fn from_volume_path(
297 allocator: Option<&CFAllocator>,
298 session: &DASession,
299 path: &CFURL,
300 ) -> Option<CFRetained<DADisk>> {
301 extern "C-unwind" {
302 fn DADiskCreateFromVolumePath(
303 allocator: Option<&CFAllocator>,
304 session: &DASession,
305 path: &CFURL,
306 ) -> Option<NonNull<DADisk>>;
307 }
308 let ret = unsafe { DADiskCreateFromVolumePath(allocator, session, path) };
309 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
310 }
311
312 /// Obtains the BSD device name for the specified disk.
313 ///
314 /// Parameter `disk`: The DADisk for which to obtain the BSD device name.
315 ///
316 /// Returns: The disk's BSD device name.
317 ///
318 /// The BSD device name can be used with opendev() to open the BSD device.
319 #[doc(alias = "DADiskGetBSDName")]
320 #[inline]
321 pub unsafe fn bsd_name(&self) -> *const c_char {
322 extern "C-unwind" {
323 fn DADiskGetBSDName(disk: &DADisk) -> *const c_char;
324 }
325 unsafe { DADiskGetBSDName(self) }
326 }
327
328 /// Obtains the Disk Arbitration description of the specified disk.
329 ///
330 /// Parameter `disk`: The DADisk for which to obtain the Disk Arbitration description.
331 ///
332 /// Returns: The disk's Disk Arbitration description.
333 ///
334 /// This function will contact Disk Arbitration to acquire the latest description
335 /// of the specified disk, unless this function is called on a disk object passed
336 /// within the context of a registered callback, in which case the description is
337 /// current as of that callback event.
338 ///
339 /// The caller of this function receives a reference to the returned object. The
340 /// caller also implicitly retains the object and is responsible for releasing it
341 /// with CFRelease().
342 #[doc(alias = "DADiskCopyDescription")]
343 #[inline]
344 pub unsafe fn description(&self) -> Option<CFRetained<CFDictionary>> {
345 extern "C-unwind" {
346 fn DADiskCopyDescription(disk: &DADisk) -> Option<NonNull<CFDictionary>>;
347 }
348 let ret = unsafe { DADiskCopyDescription(self) };
349 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
350 }
351
352 /// Obtain the associated whole disk object for the specified disk.
353 ///
354 /// Parameter `disk`: The disk object.
355 ///
356 /// Returns: The disk's associated whole disk object.
357 ///
358 /// The caller of this function receives a reference to the returned object. The
359 /// caller also implicitly retains the object and is responsible for releasing it
360 /// with CFRelease().
361 #[doc(alias = "DADiskCopyWholeDisk")]
362 #[inline]
363 pub unsafe fn whole_disk(&self) -> Option<CFRetained<DADisk>> {
364 extern "C-unwind" {
365 fn DADiskCopyWholeDisk(disk: &DADisk) -> Option<NonNull<DADisk>>;
366 }
367 let ret = unsafe { DADiskCopyWholeDisk(self) };
368 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
369 }
370}
371
372#[cfg(feature = "DASession")]
373#[deprecated = "renamed to `DADisk::from_bsd_name`"]
374#[inline]
375pub unsafe extern "C-unwind" fn DADiskCreateFromBSDName(
376 allocator: Option<&CFAllocator>,
377 session: &DASession,
378 name: NonNull<c_char>,
379) -> Option<CFRetained<DADisk>> {
380 extern "C-unwind" {
381 fn DADiskCreateFromBSDName(
382 allocator: Option<&CFAllocator>,
383 session: &DASession,
384 name: NonNull<c_char>,
385 ) -> Option<NonNull<DADisk>>;
386 }
387 let ret = unsafe { DADiskCreateFromBSDName(allocator, session, name) };
388 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
389}
390
391#[cfg(feature = "DASession")]
392#[deprecated = "renamed to `DADisk::from_volume_path`"]
393#[inline]
394pub unsafe extern "C-unwind" fn DADiskCreateFromVolumePath(
395 allocator: Option<&CFAllocator>,
396 session: &DASession,
397 path: &CFURL,
398) -> Option<CFRetained<DADisk>> {
399 extern "C-unwind" {
400 fn DADiskCreateFromVolumePath(
401 allocator: Option<&CFAllocator>,
402 session: &DASession,
403 path: &CFURL,
404 ) -> Option<NonNull<DADisk>>;
405 }
406 let ret = unsafe { DADiskCreateFromVolumePath(allocator, session, path) };
407 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
408}
409
410extern "C-unwind" {
411 #[deprecated = "renamed to `DADisk::bsd_name`"]
412 pub fn DADiskGetBSDName(disk: &DADisk) -> *const c_char;
413}
414
415#[deprecated = "renamed to `DADisk::description`"]
416#[inline]
417pub unsafe extern "C-unwind" fn DADiskCopyDescription(
418 disk: &DADisk,
419) -> Option<CFRetained<CFDictionary>> {
420 extern "C-unwind" {
421 fn DADiskCopyDescription(disk: &DADisk) -> Option<NonNull<CFDictionary>>;
422 }
423 let ret = unsafe { DADiskCopyDescription(disk) };
424 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
425}
426
427#[deprecated = "renamed to `DADisk::whole_disk`"]
428#[inline]
429pub unsafe extern "C-unwind" fn DADiskCopyWholeDisk(disk: &DADisk) -> Option<CFRetained<DADisk>> {
430 extern "C-unwind" {
431 fn DADiskCopyWholeDisk(disk: &DADisk) -> Option<NonNull<DADisk>>;
432 }
433 let ret = unsafe { DADiskCopyWholeDisk(disk) };
434 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
435}