objc2_core_services/generated/OSServices/
CSIdentityQuery.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7use objc2_core_foundation::*;
8
9use crate::*;
10
11#[cfg(feature = "CSIdentity")]
12unsafe impl ConcreteType for CSIdentityQuery {
13    #[doc(alias = "CSIdentityQueryGetTypeID")]
14    #[inline]
15    fn type_id() -> CFTypeID {
16        extern "C-unwind" {
17            fn CSIdentityQueryGetTypeID() -> CFTypeID;
18        }
19        unsafe { CSIdentityQueryGetTypeID() }
20    }
21}
22
23/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityquerygenerateupdateevents?language=objc)
24pub const kCSIdentityQueryGenerateUpdateEvents: c_uint = 0x0001;
25/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityqueryincludehiddenidentities?language=objc)
26pub const kCSIdentityQueryIncludeHiddenIdentities: c_uint = 0x0002;
27
28/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/csidentityqueryflags?language=objc)
29pub type CSIdentityQueryFlags = CFOptionFlags;
30
31/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityquerystringequals?language=objc)
32pub const kCSIdentityQueryStringEquals: c_uint = 1;
33/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityquerystringbeginswith?language=objc)
34pub const kCSIdentityQueryStringBeginsWith: c_uint = 2;
35
36/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/csidentityquerystringcomparisonmethod?language=objc)
37pub type CSIdentityQueryStringComparisonMethod = CFIndex;
38
39#[cfg(feature = "CSIdentity")]
40impl CSIdentityQuery {
41    #[doc(alias = "CSIdentityQueryCreate")]
42    #[cfg(all(feature = "CSIdentity", feature = "CSIdentityAuthority"))]
43    #[inline]
44    pub unsafe fn new(
45        allocator: Option<&CFAllocator>,
46        identity_class: CSIdentityClass,
47        authority: Option<&CSIdentityAuthority>,
48    ) -> Option<CFRetained<CSIdentityQuery>> {
49        extern "C-unwind" {
50            fn CSIdentityQueryCreate(
51                allocator: Option<&CFAllocator>,
52                identity_class: CSIdentityClass,
53                authority: Option<&CSIdentityAuthority>,
54            ) -> Option<NonNull<CSIdentityQuery>>;
55        }
56        let ret = unsafe { CSIdentityQueryCreate(allocator, identity_class, authority) };
57        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
58    }
59
60    #[doc(alias = "CSIdentityQueryCreateForName")]
61    #[cfg(all(feature = "CSIdentity", feature = "CSIdentityAuthority"))]
62    #[inline]
63    pub unsafe fn new_for_name(
64        allocator: Option<&CFAllocator>,
65        name: Option<&CFString>,
66        comparison_method: CSIdentityQueryStringComparisonMethod,
67        identity_class: CSIdentityClass,
68        authority: Option<&CSIdentityAuthority>,
69    ) -> Option<CFRetained<CSIdentityQuery>> {
70        extern "C-unwind" {
71            fn CSIdentityQueryCreateForName(
72                allocator: Option<&CFAllocator>,
73                name: Option<&CFString>,
74                comparison_method: CSIdentityQueryStringComparisonMethod,
75                identity_class: CSIdentityClass,
76                authority: Option<&CSIdentityAuthority>,
77            ) -> Option<NonNull<CSIdentityQuery>>;
78        }
79        let ret = unsafe {
80            CSIdentityQueryCreateForName(
81                allocator,
82                name,
83                comparison_method,
84                identity_class,
85                authority,
86            )
87        };
88        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
89    }
90
91    #[doc(alias = "CSIdentityQueryCreateForUUID")]
92    #[cfg(all(feature = "CSIdentity", feature = "CSIdentityAuthority"))]
93    #[inline]
94    pub unsafe fn new_for_uuid(
95        allocator: Option<&CFAllocator>,
96        uuid: Option<&CFUUID>,
97        authority: Option<&CSIdentityAuthority>,
98    ) -> Option<CFRetained<CSIdentityQuery>> {
99        extern "C-unwind" {
100            fn CSIdentityQueryCreateForUUID(
101                allocator: Option<&CFAllocator>,
102                uuid: Option<&CFUUID>,
103                authority: Option<&CSIdentityAuthority>,
104            ) -> Option<NonNull<CSIdentityQuery>>;
105        }
106        let ret = unsafe { CSIdentityQueryCreateForUUID(allocator, uuid, authority) };
107        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
108    }
109
110    #[doc(alias = "CSIdentityQueryCreateForPosixID")]
111    #[cfg(all(
112        feature = "CSIdentity",
113        feature = "CSIdentityAuthority",
114        feature = "libc"
115    ))]
116    #[inline]
117    pub unsafe fn new_for_posix_id(
118        allocator: Option<&CFAllocator>,
119        posix_id: libc::id_t,
120        identity_class: CSIdentityClass,
121        authority: Option<&CSIdentityAuthority>,
122    ) -> Option<CFRetained<CSIdentityQuery>> {
123        extern "C-unwind" {
124            fn CSIdentityQueryCreateForPosixID(
125                allocator: Option<&CFAllocator>,
126                posix_id: libc::id_t,
127                identity_class: CSIdentityClass,
128                authority: Option<&CSIdentityAuthority>,
129            ) -> Option<NonNull<CSIdentityQuery>>;
130        }
131        let ret = unsafe {
132            CSIdentityQueryCreateForPosixID(allocator, posix_id, identity_class, authority)
133        };
134        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
135    }
136
137    #[doc(alias = "CSIdentityQueryCreateForPersistentReference")]
138    #[cfg(feature = "CSIdentity")]
139    #[inline]
140    pub unsafe fn new_for_persistent_reference(
141        allocator: Option<&CFAllocator>,
142        reference_data: Option<&CFData>,
143    ) -> Option<CFRetained<CSIdentityQuery>> {
144        extern "C-unwind" {
145            fn CSIdentityQueryCreateForPersistentReference(
146                allocator: Option<&CFAllocator>,
147                reference_data: Option<&CFData>,
148            ) -> Option<NonNull<CSIdentityQuery>>;
149        }
150        let ret = unsafe { CSIdentityQueryCreateForPersistentReference(allocator, reference_data) };
151        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
152    }
153
154    #[doc(alias = "CSIdentityQueryCreateForCurrentUser")]
155    #[cfg(feature = "CSIdentity")]
156    #[inline]
157    pub unsafe fn new_for_current_user(
158        allocator: Option<&CFAllocator>,
159    ) -> Option<CFRetained<CSIdentityQuery>> {
160        extern "C-unwind" {
161            fn CSIdentityQueryCreateForCurrentUser(
162                allocator: Option<&CFAllocator>,
163            ) -> Option<NonNull<CSIdentityQuery>>;
164        }
165        let ret = unsafe { CSIdentityQueryCreateForCurrentUser(allocator) };
166        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
167    }
168
169    #[doc(alias = "CSIdentityQueryCopyResults")]
170    #[cfg(feature = "CSIdentity")]
171    #[inline]
172    pub unsafe fn results(self: &CSIdentityQuery) -> Option<CFRetained<CFArray>> {
173        extern "C-unwind" {
174            fn CSIdentityQueryCopyResults(query: &CSIdentityQuery) -> Option<NonNull<CFArray>>;
175        }
176        let ret = unsafe { CSIdentityQueryCopyResults(self) };
177        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
178    }
179
180    #[doc(alias = "CSIdentityQueryExecute")]
181    #[cfg(feature = "CSIdentity")]
182    #[inline]
183    pub unsafe fn execute(
184        self: &CSIdentityQuery,
185        flags: CSIdentityQueryFlags,
186        error: *mut *mut CFError,
187    ) -> bool {
188        extern "C-unwind" {
189            fn CSIdentityQueryExecute(
190                query: &CSIdentityQuery,
191                flags: CSIdentityQueryFlags,
192                error: *mut *mut CFError,
193            ) -> Boolean;
194        }
195        let ret = unsafe { CSIdentityQueryExecute(self, flags, error) };
196        ret != 0
197    }
198}
199
200/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityqueryeventsearchphasefinished?language=objc)
201pub const kCSIdentityQueryEventSearchPhaseFinished: c_uint = 1;
202/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityqueryeventresultsadded?language=objc)
203pub const kCSIdentityQueryEventResultsAdded: c_uint = 2;
204/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityqueryeventresultschanged?language=objc)
205pub const kCSIdentityQueryEventResultsChanged: c_uint = 3;
206/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityqueryeventresultsremoved?language=objc)
207pub const kCSIdentityQueryEventResultsRemoved: c_uint = 4;
208/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kcsidentityqueryeventerroroccurred?language=objc)
209pub const kCSIdentityQueryEventErrorOccurred: c_uint = 5;
210
211/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/csidentityqueryevent?language=objc)
212pub type CSIdentityQueryEvent = CFIndex;
213
214/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/csidentityqueryreceiveeventcallback?language=objc)
215#[cfg(feature = "CSIdentity")]
216pub type CSIdentityQueryReceiveEventCallback = Option<
217    unsafe extern "C-unwind" fn(
218        *mut CSIdentityQuery,
219        CSIdentityQueryEvent,
220        *const CFArray,
221        *mut CFError,
222        *mut c_void,
223    ),
224>;
225
226/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/csidentityqueryclientcontext?language=objc)
227#[cfg(feature = "CSIdentity")]
228#[repr(C)]
229#[derive(Clone, Copy, Debug, PartialEq)]
230pub struct CSIdentityQueryClientContext {
231    pub version: CFIndex,
232    pub info: *mut c_void,
233    pub retainInfo: CFAllocatorRetainCallBack,
234    pub releaseInfo: CFAllocatorReleaseCallBack,
235    pub copyInfoDescription: CFAllocatorCopyDescriptionCallBack,
236    pub receiveEvent: CSIdentityQueryReceiveEventCallback,
237}
238
239#[cfg(all(feature = "CSIdentity", feature = "objc2"))]
240unsafe impl Encode for CSIdentityQueryClientContext {
241    const ENCODING: Encoding = Encoding::Struct(
242        "CSIdentityQueryClientContext",
243        &[
244            <CFIndex>::ENCODING,
245            <*mut c_void>::ENCODING,
246            <CFAllocatorRetainCallBack>::ENCODING,
247            <CFAllocatorReleaseCallBack>::ENCODING,
248            <CFAllocatorCopyDescriptionCallBack>::ENCODING,
249            <CSIdentityQueryReceiveEventCallback>::ENCODING,
250        ],
251    );
252}
253
254#[cfg(all(feature = "CSIdentity", feature = "objc2"))]
255unsafe impl RefEncode for CSIdentityQueryClientContext {
256    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
257}
258
259#[cfg(feature = "CSIdentity")]
260impl CSIdentityQuery {
261    #[doc(alias = "CSIdentityQueryExecuteAsynchronously")]
262    #[cfg(feature = "CSIdentity")]
263    #[inline]
264    pub unsafe fn execute_asynchronously(
265        self: &CSIdentityQuery,
266        flags: CSIdentityQueryFlags,
267        client_context: *const CSIdentityQueryClientContext,
268        run_loop: Option<&CFRunLoop>,
269        run_loop_mode: Option<&CFString>,
270    ) -> bool {
271        extern "C-unwind" {
272            fn CSIdentityQueryExecuteAsynchronously(
273                query: &CSIdentityQuery,
274                flags: CSIdentityQueryFlags,
275                client_context: *const CSIdentityQueryClientContext,
276                run_loop: Option<&CFRunLoop>,
277                run_loop_mode: Option<&CFString>,
278            ) -> Boolean;
279        }
280        let ret = unsafe {
281            CSIdentityQueryExecuteAsynchronously(
282                self,
283                flags,
284                client_context,
285                run_loop,
286                run_loop_mode,
287            )
288        };
289        ret != 0
290    }
291
292    #[doc(alias = "CSIdentityQueryStop")]
293    #[cfg(feature = "CSIdentity")]
294    #[inline]
295    pub unsafe fn stop(self: &CSIdentityQuery) {
296        extern "C-unwind" {
297            fn CSIdentityQueryStop(query: &CSIdentityQuery);
298        }
299        unsafe { CSIdentityQueryStop(self) }
300    }
301}
302
303#[cfg(all(feature = "CSIdentity", feature = "CSIdentityAuthority"))]
304#[deprecated = "renamed to `CSIdentityQuery::new`"]
305#[inline]
306pub unsafe extern "C-unwind" fn CSIdentityQueryCreate(
307    allocator: Option<&CFAllocator>,
308    identity_class: CSIdentityClass,
309    authority: Option<&CSIdentityAuthority>,
310) -> Option<CFRetained<CSIdentityQuery>> {
311    extern "C-unwind" {
312        fn CSIdentityQueryCreate(
313            allocator: Option<&CFAllocator>,
314            identity_class: CSIdentityClass,
315            authority: Option<&CSIdentityAuthority>,
316        ) -> Option<NonNull<CSIdentityQuery>>;
317    }
318    let ret = unsafe { CSIdentityQueryCreate(allocator, identity_class, authority) };
319    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
320}
321
322#[cfg(all(feature = "CSIdentity", feature = "CSIdentityAuthority"))]
323#[deprecated = "renamed to `CSIdentityQuery::new_for_name`"]
324#[inline]
325pub unsafe extern "C-unwind" fn CSIdentityQueryCreateForName(
326    allocator: Option<&CFAllocator>,
327    name: Option<&CFString>,
328    comparison_method: CSIdentityQueryStringComparisonMethod,
329    identity_class: CSIdentityClass,
330    authority: Option<&CSIdentityAuthority>,
331) -> Option<CFRetained<CSIdentityQuery>> {
332    extern "C-unwind" {
333        fn CSIdentityQueryCreateForName(
334            allocator: Option<&CFAllocator>,
335            name: Option<&CFString>,
336            comparison_method: CSIdentityQueryStringComparisonMethod,
337            identity_class: CSIdentityClass,
338            authority: Option<&CSIdentityAuthority>,
339        ) -> Option<NonNull<CSIdentityQuery>>;
340    }
341    let ret = unsafe {
342        CSIdentityQueryCreateForName(
343            allocator,
344            name,
345            comparison_method,
346            identity_class,
347            authority,
348        )
349    };
350    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
351}
352
353#[cfg(all(feature = "CSIdentity", feature = "CSIdentityAuthority"))]
354#[deprecated = "renamed to `CSIdentityQuery::new_for_uuid`"]
355#[inline]
356pub unsafe extern "C-unwind" fn CSIdentityQueryCreateForUUID(
357    allocator: Option<&CFAllocator>,
358    uuid: Option<&CFUUID>,
359    authority: Option<&CSIdentityAuthority>,
360) -> Option<CFRetained<CSIdentityQuery>> {
361    extern "C-unwind" {
362        fn CSIdentityQueryCreateForUUID(
363            allocator: Option<&CFAllocator>,
364            uuid: Option<&CFUUID>,
365            authority: Option<&CSIdentityAuthority>,
366        ) -> Option<NonNull<CSIdentityQuery>>;
367    }
368    let ret = unsafe { CSIdentityQueryCreateForUUID(allocator, uuid, authority) };
369    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
370}
371
372#[cfg(all(
373    feature = "CSIdentity",
374    feature = "CSIdentityAuthority",
375    feature = "libc"
376))]
377#[deprecated = "renamed to `CSIdentityQuery::new_for_posix_id`"]
378#[inline]
379pub unsafe extern "C-unwind" fn CSIdentityQueryCreateForPosixID(
380    allocator: Option<&CFAllocator>,
381    posix_id: libc::id_t,
382    identity_class: CSIdentityClass,
383    authority: Option<&CSIdentityAuthority>,
384) -> Option<CFRetained<CSIdentityQuery>> {
385    extern "C-unwind" {
386        fn CSIdentityQueryCreateForPosixID(
387            allocator: Option<&CFAllocator>,
388            posix_id: libc::id_t,
389            identity_class: CSIdentityClass,
390            authority: Option<&CSIdentityAuthority>,
391        ) -> Option<NonNull<CSIdentityQuery>>;
392    }
393    let ret =
394        unsafe { CSIdentityQueryCreateForPosixID(allocator, posix_id, identity_class, authority) };
395    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
396}
397
398#[cfg(feature = "CSIdentity")]
399#[deprecated = "renamed to `CSIdentityQuery::new_for_persistent_reference`"]
400#[inline]
401pub unsafe extern "C-unwind" fn CSIdentityQueryCreateForPersistentReference(
402    allocator: Option<&CFAllocator>,
403    reference_data: Option<&CFData>,
404) -> Option<CFRetained<CSIdentityQuery>> {
405    extern "C-unwind" {
406        fn CSIdentityQueryCreateForPersistentReference(
407            allocator: Option<&CFAllocator>,
408            reference_data: Option<&CFData>,
409        ) -> Option<NonNull<CSIdentityQuery>>;
410    }
411    let ret = unsafe { CSIdentityQueryCreateForPersistentReference(allocator, reference_data) };
412    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
413}
414
415#[cfg(feature = "CSIdentity")]
416#[deprecated = "renamed to `CSIdentityQuery::new_for_current_user`"]
417#[inline]
418pub unsafe extern "C-unwind" fn CSIdentityQueryCreateForCurrentUser(
419    allocator: Option<&CFAllocator>,
420) -> Option<CFRetained<CSIdentityQuery>> {
421    extern "C-unwind" {
422        fn CSIdentityQueryCreateForCurrentUser(
423            allocator: Option<&CFAllocator>,
424        ) -> Option<NonNull<CSIdentityQuery>>;
425    }
426    let ret = unsafe { CSIdentityQueryCreateForCurrentUser(allocator) };
427    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
428}
429
430#[cfg(feature = "CSIdentity")]
431#[deprecated = "renamed to `CSIdentityQuery::results`"]
432#[inline]
433pub unsafe extern "C-unwind" fn CSIdentityQueryCopyResults(
434    query: &CSIdentityQuery,
435) -> Option<CFRetained<CFArray>> {
436    extern "C-unwind" {
437        fn CSIdentityQueryCopyResults(query: &CSIdentityQuery) -> Option<NonNull<CFArray>>;
438    }
439    let ret = unsafe { CSIdentityQueryCopyResults(query) };
440    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
441}
442
443#[cfg(feature = "CSIdentity")]
444#[deprecated = "renamed to `CSIdentityQuery::execute`"]
445#[inline]
446pub unsafe extern "C-unwind" fn CSIdentityQueryExecute(
447    query: &CSIdentityQuery,
448    flags: CSIdentityQueryFlags,
449    error: *mut *mut CFError,
450) -> bool {
451    extern "C-unwind" {
452        fn CSIdentityQueryExecute(
453            query: &CSIdentityQuery,
454            flags: CSIdentityQueryFlags,
455            error: *mut *mut CFError,
456        ) -> Boolean;
457    }
458    let ret = unsafe { CSIdentityQueryExecute(query, flags, error) };
459    ret != 0
460}
461
462#[cfg(feature = "CSIdentity")]
463#[deprecated = "renamed to `CSIdentityQuery::execute_asynchronously`"]
464#[inline]
465pub unsafe extern "C-unwind" fn CSIdentityQueryExecuteAsynchronously(
466    query: &CSIdentityQuery,
467    flags: CSIdentityQueryFlags,
468    client_context: *const CSIdentityQueryClientContext,
469    run_loop: Option<&CFRunLoop>,
470    run_loop_mode: Option<&CFString>,
471) -> bool {
472    extern "C-unwind" {
473        fn CSIdentityQueryExecuteAsynchronously(
474            query: &CSIdentityQuery,
475            flags: CSIdentityQueryFlags,
476            client_context: *const CSIdentityQueryClientContext,
477            run_loop: Option<&CFRunLoop>,
478            run_loop_mode: Option<&CFString>,
479        ) -> Boolean;
480    }
481    let ret = unsafe {
482        CSIdentityQueryExecuteAsynchronously(query, flags, client_context, run_loop, run_loop_mode)
483    };
484    ret != 0
485}
486
487extern "C-unwind" {
488    #[cfg(feature = "CSIdentity")]
489    #[deprecated = "renamed to `CSIdentityQuery::stop`"]
490    pub fn CSIdentityQueryStop(query: &CSIdentityQuery);
491}