objc2_core_foundation/generated/
CFUUID.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfuuid?language=objc)
12#[doc(alias = "CFUUIDRef")]
13#[repr(C)]
14pub struct CFUUID {
15    inner: [u8; 0],
16    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
17}
18
19cf_type!(
20    unsafe impl CFUUID {}
21);
22#[cfg(feature = "objc2")]
23cf_objc2_type!(
24    unsafe impl RefEncode<"__CFUUID"> for CFUUID {}
25);
26
27/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfuuidbytes?language=objc)
28#[repr(C)]
29#[derive(Clone, Copy, Debug, PartialEq)]
30pub struct CFUUIDBytes {
31    pub byte0: u8,
32    pub byte1: u8,
33    pub byte2: u8,
34    pub byte3: u8,
35    pub byte4: u8,
36    pub byte5: u8,
37    pub byte6: u8,
38    pub byte7: u8,
39    pub byte8: u8,
40    pub byte9: u8,
41    pub byte10: u8,
42    pub byte11: u8,
43    pub byte12: u8,
44    pub byte13: u8,
45    pub byte14: u8,
46    pub byte15: u8,
47}
48
49#[cfg(feature = "objc2")]
50unsafe impl Encode for CFUUIDBytes {
51    const ENCODING: Encoding = Encoding::Struct(
52        "?",
53        &[
54            <u8>::ENCODING,
55            <u8>::ENCODING,
56            <u8>::ENCODING,
57            <u8>::ENCODING,
58            <u8>::ENCODING,
59            <u8>::ENCODING,
60            <u8>::ENCODING,
61            <u8>::ENCODING,
62            <u8>::ENCODING,
63            <u8>::ENCODING,
64            <u8>::ENCODING,
65            <u8>::ENCODING,
66            <u8>::ENCODING,
67            <u8>::ENCODING,
68            <u8>::ENCODING,
69            <u8>::ENCODING,
70        ],
71    );
72}
73
74#[cfg(feature = "objc2")]
75unsafe impl RefEncode for CFUUIDBytes {
76    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
77}
78
79unsafe impl ConcreteType for CFUUID {
80    #[doc(alias = "CFUUIDGetTypeID")]
81    #[inline]
82    fn type_id() -> CFTypeID {
83        extern "C-unwind" {
84            fn CFUUIDGetTypeID() -> CFTypeID;
85        }
86        unsafe { CFUUIDGetTypeID() }
87    }
88}
89
90impl CFUUID {
91    #[doc(alias = "CFUUIDCreate")]
92    #[inline]
93    pub fn new(alloc: Option<&CFAllocator>) -> Option<CFRetained<CFUUID>> {
94        extern "C-unwind" {
95            fn CFUUIDCreate(alloc: Option<&CFAllocator>) -> Option<NonNull<CFUUID>>;
96        }
97        let ret = unsafe { CFUUIDCreate(alloc) };
98        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
99    }
100
101    #[doc(alias = "CFUUIDCreateWithBytes")]
102    #[inline]
103    pub fn with_bytes(
104        alloc: Option<&CFAllocator>,
105        byte0: u8,
106        byte1: u8,
107        byte2: u8,
108        byte3: u8,
109        byte4: u8,
110        byte5: u8,
111        byte6: u8,
112        byte7: u8,
113        byte8: u8,
114        byte9: u8,
115        byte10: u8,
116        byte11: u8,
117        byte12: u8,
118        byte13: u8,
119        byte14: u8,
120        byte15: u8,
121    ) -> Option<CFRetained<CFUUID>> {
122        extern "C-unwind" {
123            fn CFUUIDCreateWithBytes(
124                alloc: Option<&CFAllocator>,
125                byte0: u8,
126                byte1: u8,
127                byte2: u8,
128                byte3: u8,
129                byte4: u8,
130                byte5: u8,
131                byte6: u8,
132                byte7: u8,
133                byte8: u8,
134                byte9: u8,
135                byte10: u8,
136                byte11: u8,
137                byte12: u8,
138                byte13: u8,
139                byte14: u8,
140                byte15: u8,
141            ) -> Option<NonNull<CFUUID>>;
142        }
143        let ret = unsafe {
144            CFUUIDCreateWithBytes(
145                alloc, byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9,
146                byte10, byte11, byte12, byte13, byte14, byte15,
147            )
148        };
149        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
150    }
151
152    #[doc(alias = "CFUUIDCreateFromString")]
153    #[inline]
154    pub fn from_string(
155        alloc: Option<&CFAllocator>,
156        uuid_str: Option<&CFString>,
157    ) -> Option<CFRetained<CFUUID>> {
158        extern "C-unwind" {
159            fn CFUUIDCreateFromString(
160                alloc: Option<&CFAllocator>,
161                uuid_str: Option<&CFString>,
162            ) -> Option<NonNull<CFUUID>>;
163        }
164        let ret = unsafe { CFUUIDCreateFromString(alloc, uuid_str) };
165        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
166    }
167
168    #[doc(alias = "CFUUIDCreateString")]
169    #[inline]
170    pub fn new_string(
171        alloc: Option<&CFAllocator>,
172        uuid: Option<&CFUUID>,
173    ) -> Option<CFRetained<CFString>> {
174        extern "C-unwind" {
175            fn CFUUIDCreateString(
176                alloc: Option<&CFAllocator>,
177                uuid: Option<&CFUUID>,
178            ) -> Option<NonNull<CFString>>;
179        }
180        let ret = unsafe { CFUUIDCreateString(alloc, uuid) };
181        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
182    }
183
184    #[doc(alias = "CFUUIDGetConstantUUIDWithBytes")]
185    #[inline]
186    pub fn constant_uuid_with_bytes(
187        alloc: Option<&CFAllocator>,
188        byte0: u8,
189        byte1: u8,
190        byte2: u8,
191        byte3: u8,
192        byte4: u8,
193        byte5: u8,
194        byte6: u8,
195        byte7: u8,
196        byte8: u8,
197        byte9: u8,
198        byte10: u8,
199        byte11: u8,
200        byte12: u8,
201        byte13: u8,
202        byte14: u8,
203        byte15: u8,
204    ) -> Option<CFRetained<CFUUID>> {
205        extern "C-unwind" {
206            fn CFUUIDGetConstantUUIDWithBytes(
207                alloc: Option<&CFAllocator>,
208                byte0: u8,
209                byte1: u8,
210                byte2: u8,
211                byte3: u8,
212                byte4: u8,
213                byte5: u8,
214                byte6: u8,
215                byte7: u8,
216                byte8: u8,
217                byte9: u8,
218                byte10: u8,
219                byte11: u8,
220                byte12: u8,
221                byte13: u8,
222                byte14: u8,
223                byte15: u8,
224            ) -> Option<NonNull<CFUUID>>;
225        }
226        let ret = unsafe {
227            CFUUIDGetConstantUUIDWithBytes(
228                alloc, byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9,
229                byte10, byte11, byte12, byte13, byte14, byte15,
230            )
231        };
232        ret.map(|ret| unsafe { CFRetained::retain(ret) })
233    }
234
235    #[doc(alias = "CFUUIDGetUUIDBytes")]
236    #[inline]
237    pub fn uuid_bytes(&self) -> CFUUIDBytes {
238        extern "C-unwind" {
239            fn CFUUIDGetUUIDBytes(uuid: &CFUUID) -> CFUUIDBytes;
240        }
241        unsafe { CFUUIDGetUUIDBytes(self) }
242    }
243
244    #[doc(alias = "CFUUIDCreateFromUUIDBytes")]
245    #[inline]
246    pub fn from_uuid_bytes(
247        alloc: Option<&CFAllocator>,
248        bytes: CFUUIDBytes,
249    ) -> Option<CFRetained<CFUUID>> {
250        extern "C-unwind" {
251            fn CFUUIDCreateFromUUIDBytes(
252                alloc: Option<&CFAllocator>,
253                bytes: CFUUIDBytes,
254            ) -> Option<NonNull<CFUUID>>;
255        }
256        let ret = unsafe { CFUUIDCreateFromUUIDBytes(alloc, bytes) };
257        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
258    }
259}
260
261#[deprecated = "renamed to `CFUUID::new`"]
262#[inline]
263pub extern "C-unwind" fn CFUUIDCreate(alloc: Option<&CFAllocator>) -> Option<CFRetained<CFUUID>> {
264    extern "C-unwind" {
265        fn CFUUIDCreate(alloc: Option<&CFAllocator>) -> Option<NonNull<CFUUID>>;
266    }
267    let ret = unsafe { CFUUIDCreate(alloc) };
268    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
269}
270
271#[deprecated = "renamed to `CFUUID::with_bytes`"]
272#[inline]
273pub extern "C-unwind" fn CFUUIDCreateWithBytes(
274    alloc: Option<&CFAllocator>,
275    byte0: u8,
276    byte1: u8,
277    byte2: u8,
278    byte3: u8,
279    byte4: u8,
280    byte5: u8,
281    byte6: u8,
282    byte7: u8,
283    byte8: u8,
284    byte9: u8,
285    byte10: u8,
286    byte11: u8,
287    byte12: u8,
288    byte13: u8,
289    byte14: u8,
290    byte15: u8,
291) -> Option<CFRetained<CFUUID>> {
292    extern "C-unwind" {
293        fn CFUUIDCreateWithBytes(
294            alloc: Option<&CFAllocator>,
295            byte0: u8,
296            byte1: u8,
297            byte2: u8,
298            byte3: u8,
299            byte4: u8,
300            byte5: u8,
301            byte6: u8,
302            byte7: u8,
303            byte8: u8,
304            byte9: u8,
305            byte10: u8,
306            byte11: u8,
307            byte12: u8,
308            byte13: u8,
309            byte14: u8,
310            byte15: u8,
311        ) -> Option<NonNull<CFUUID>>;
312    }
313    let ret = unsafe {
314        CFUUIDCreateWithBytes(
315            alloc, byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10,
316            byte11, byte12, byte13, byte14, byte15,
317        )
318    };
319    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
320}
321
322#[deprecated = "renamed to `CFUUID::from_string`"]
323#[inline]
324pub extern "C-unwind" fn CFUUIDCreateFromString(
325    alloc: Option<&CFAllocator>,
326    uuid_str: Option<&CFString>,
327) -> Option<CFRetained<CFUUID>> {
328    extern "C-unwind" {
329        fn CFUUIDCreateFromString(
330            alloc: Option<&CFAllocator>,
331            uuid_str: Option<&CFString>,
332        ) -> Option<NonNull<CFUUID>>;
333    }
334    let ret = unsafe { CFUUIDCreateFromString(alloc, uuid_str) };
335    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
336}
337
338#[deprecated = "renamed to `CFUUID::new_string`"]
339#[inline]
340pub extern "C-unwind" fn CFUUIDCreateString(
341    alloc: Option<&CFAllocator>,
342    uuid: Option<&CFUUID>,
343) -> Option<CFRetained<CFString>> {
344    extern "C-unwind" {
345        fn CFUUIDCreateString(
346            alloc: Option<&CFAllocator>,
347            uuid: Option<&CFUUID>,
348        ) -> Option<NonNull<CFString>>;
349    }
350    let ret = unsafe { CFUUIDCreateString(alloc, uuid) };
351    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
352}
353
354#[deprecated = "renamed to `CFUUID::constant_uuid_with_bytes`"]
355#[inline]
356pub extern "C-unwind" fn CFUUIDGetConstantUUIDWithBytes(
357    alloc: Option<&CFAllocator>,
358    byte0: u8,
359    byte1: u8,
360    byte2: u8,
361    byte3: u8,
362    byte4: u8,
363    byte5: u8,
364    byte6: u8,
365    byte7: u8,
366    byte8: u8,
367    byte9: u8,
368    byte10: u8,
369    byte11: u8,
370    byte12: u8,
371    byte13: u8,
372    byte14: u8,
373    byte15: u8,
374) -> Option<CFRetained<CFUUID>> {
375    extern "C-unwind" {
376        fn CFUUIDGetConstantUUIDWithBytes(
377            alloc: Option<&CFAllocator>,
378            byte0: u8,
379            byte1: u8,
380            byte2: u8,
381            byte3: u8,
382            byte4: u8,
383            byte5: u8,
384            byte6: u8,
385            byte7: u8,
386            byte8: u8,
387            byte9: u8,
388            byte10: u8,
389            byte11: u8,
390            byte12: u8,
391            byte13: u8,
392            byte14: u8,
393            byte15: u8,
394        ) -> Option<NonNull<CFUUID>>;
395    }
396    let ret = unsafe {
397        CFUUIDGetConstantUUIDWithBytes(
398            alloc, byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10,
399            byte11, byte12, byte13, byte14, byte15,
400        )
401    };
402    ret.map(|ret| unsafe { CFRetained::retain(ret) })
403}
404
405#[deprecated = "renamed to `CFUUID::uuid_bytes`"]
406#[inline]
407pub extern "C-unwind" fn CFUUIDGetUUIDBytes(uuid: &CFUUID) -> CFUUIDBytes {
408    extern "C-unwind" {
409        fn CFUUIDGetUUIDBytes(uuid: &CFUUID) -> CFUUIDBytes;
410    }
411    unsafe { CFUUIDGetUUIDBytes(uuid) }
412}
413
414#[deprecated = "renamed to `CFUUID::from_uuid_bytes`"]
415#[inline]
416pub extern "C-unwind" fn CFUUIDCreateFromUUIDBytes(
417    alloc: Option<&CFAllocator>,
418    bytes: CFUUIDBytes,
419) -> Option<CFRetained<CFUUID>> {
420    extern "C-unwind" {
421        fn CFUUIDCreateFromUUIDBytes(
422            alloc: Option<&CFAllocator>,
423            bytes: CFUUIDBytes,
424        ) -> Option<NonNull<CFUUID>>;
425    }
426    let ret = unsafe { CFUUIDCreateFromUUIDBytes(alloc, bytes) };
427    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
428}