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