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