objc2_cf_network/generated/
CFHost.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
13/// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/cfhost?language=objc)
14#[doc(alias = "CFHostRef")]
15#[repr(C)]
16pub struct CFHost {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl CFHost {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"__CFHost"> for CFHost {}
27);
28
29extern "C" {
30    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreamerrordomainnetdb?language=objc)
31    pub static kCFStreamErrorDomainNetDB: i32;
32}
33
34extern "C" {
35    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfstreamerrordomainsystemconfiguration?language=objc)
36    pub static kCFStreamErrorDomainSystemConfiguration: i32;
37}
38
39/// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/cfhostinfotype?language=objc)
40// NS_ENUM
41#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct CFHostInfoType(pub c_int);
44impl CFHostInfoType {
45    #[doc(alias = "kCFHostAddresses")]
46    pub const Addresses: Self = Self(0);
47    #[doc(alias = "kCFHostNames")]
48    pub const Names: Self = Self(1);
49    #[doc(alias = "kCFHostReachability")]
50    pub const Reachability: Self = Self(2);
51}
52
53#[cfg(feature = "objc2")]
54unsafe impl Encode for CFHostInfoType {
55    const ENCODING: Encoding = c_int::ENCODING;
56}
57
58#[cfg(feature = "objc2")]
59unsafe impl RefEncode for CFHostInfoType {
60    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63/// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/cfhostclientcontext?language=objc)
64#[repr(C, packed(2))]
65#[allow(unpredictable_function_pointer_comparisons)]
66#[derive(Clone, Copy, Debug, PartialEq)]
67pub struct CFHostClientContext {
68    pub version: CFIndex,
69    pub info: *mut c_void,
70    pub retain: CFAllocatorRetainCallBack,
71    pub release: CFAllocatorReleaseCallBack,
72    pub copyDescription: CFAllocatorCopyDescriptionCallBack,
73}
74
75#[cfg(feature = "objc2")]
76unsafe impl Encode for CFHostClientContext {
77    const ENCODING: Encoding = Encoding::Struct(
78        "CFHostClientContext",
79        &[
80            <CFIndex>::ENCODING,
81            <*mut c_void>::ENCODING,
82            <CFAllocatorRetainCallBack>::ENCODING,
83            <CFAllocatorReleaseCallBack>::ENCODING,
84            <CFAllocatorCopyDescriptionCallBack>::ENCODING,
85        ],
86    );
87}
88
89#[cfg(feature = "objc2")]
90unsafe impl RefEncode for CFHostClientContext {
91    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
92}
93
94/// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/cfhostclientcallback?language=objc)
95pub type CFHostClientCallBack = Option<
96    unsafe extern "C-unwind" fn(NonNull<CFHost>, CFHostInfoType, *const CFStreamError, *mut c_void),
97>;
98
99unsafe impl ConcreteType for CFHost {
100    #[doc(alias = "CFHostGetTypeID")]
101    #[inline]
102    fn type_id() -> CFTypeID {
103        extern "C-unwind" {
104            fn CFHostGetTypeID() -> CFTypeID;
105        }
106        unsafe { CFHostGetTypeID() }
107    }
108}
109
110impl CFHost {
111    #[doc(alias = "CFHostCreateWithName")]
112    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
113    #[inline]
114    pub unsafe fn with_name(
115        allocator: Option<&CFAllocator>,
116        hostname: &CFString,
117    ) -> CFRetained<CFHost> {
118        extern "C-unwind" {
119            fn CFHostCreateWithName(
120                allocator: Option<&CFAllocator>,
121                hostname: &CFString,
122            ) -> Option<NonNull<CFHost>>;
123        }
124        let ret = unsafe { CFHostCreateWithName(allocator, hostname) };
125        let ret =
126            ret.expect("function was marked as returning non-null, but actually returned NULL");
127        unsafe { CFRetained::from_raw(ret) }
128    }
129
130    #[doc(alias = "CFHostCreateWithAddress")]
131    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
132    #[inline]
133    pub unsafe fn with_address(
134        allocator: Option<&CFAllocator>,
135        addr: &CFData,
136    ) -> CFRetained<CFHost> {
137        extern "C-unwind" {
138            fn CFHostCreateWithAddress(
139                allocator: Option<&CFAllocator>,
140                addr: &CFData,
141            ) -> Option<NonNull<CFHost>>;
142        }
143        let ret = unsafe { CFHostCreateWithAddress(allocator, addr) };
144        let ret =
145            ret.expect("function was marked as returning non-null, but actually returned NULL");
146        unsafe { CFRetained::from_raw(ret) }
147    }
148
149    #[doc(alias = "CFHostCreateCopy")]
150    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
151    #[inline]
152    pub unsafe fn new_copy(alloc: Option<&CFAllocator>, host: &CFHost) -> CFRetained<CFHost> {
153        extern "C-unwind" {
154            fn CFHostCreateCopy(
155                alloc: Option<&CFAllocator>,
156                host: &CFHost,
157            ) -> Option<NonNull<CFHost>>;
158        }
159        let ret = unsafe { CFHostCreateCopy(alloc, host) };
160        let ret =
161            ret.expect("function was marked as returning non-null, but actually returned NULL");
162        unsafe { CFRetained::from_raw(ret) }
163    }
164
165    /// # Safety
166    ///
167    /// `error` must be a valid pointer or null.
168    #[doc(alias = "CFHostStartInfoResolution")]
169    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
170    #[inline]
171    pub unsafe fn start_info_resolution(
172        &self,
173        info: CFHostInfoType,
174        error: *mut CFStreamError,
175    ) -> bool {
176        extern "C-unwind" {
177            fn CFHostStartInfoResolution(
178                the_host: &CFHost,
179                info: CFHostInfoType,
180                error: *mut CFStreamError,
181            ) -> Boolean;
182        }
183        let ret = unsafe { CFHostStartInfoResolution(self, info, error) };
184        ret != 0
185    }
186
187    /// # Safety
188    ///
189    /// `has_been_resolved` must be a valid pointer or null.
190    #[doc(alias = "CFHostGetAddressing")]
191    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
192    #[inline]
193    pub unsafe fn addressing(
194        &self,
195        has_been_resolved: *mut Boolean,
196    ) -> Option<CFRetained<CFArray>> {
197        extern "C-unwind" {
198            fn CFHostGetAddressing(
199                the_host: &CFHost,
200                has_been_resolved: *mut Boolean,
201            ) -> Option<NonNull<CFArray>>;
202        }
203        let ret = unsafe { CFHostGetAddressing(self, has_been_resolved) };
204        ret.map(|ret| unsafe { CFRetained::retain(ret) })
205    }
206
207    /// # Safety
208    ///
209    /// `has_been_resolved` must be a valid pointer or null.
210    #[doc(alias = "CFHostGetNames")]
211    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
212    #[inline]
213    pub unsafe fn names(&self, has_been_resolved: *mut Boolean) -> Option<CFRetained<CFArray>> {
214        extern "C-unwind" {
215            fn CFHostGetNames(
216                the_host: &CFHost,
217                has_been_resolved: *mut Boolean,
218            ) -> Option<NonNull<CFArray>>;
219        }
220        let ret = unsafe { CFHostGetNames(self, has_been_resolved) };
221        ret.map(|ret| unsafe { CFRetained::retain(ret) })
222    }
223
224    /// # Safety
225    ///
226    /// `has_been_resolved` must be a valid pointer or null.
227    #[doc(alias = "CFHostGetReachability")]
228    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
229    #[inline]
230    pub unsafe fn reachability(
231        &self,
232        has_been_resolved: *mut Boolean,
233    ) -> Option<CFRetained<CFData>> {
234        extern "C-unwind" {
235            fn CFHostGetReachability(
236                the_host: &CFHost,
237                has_been_resolved: *mut Boolean,
238            ) -> Option<NonNull<CFData>>;
239        }
240        let ret = unsafe { CFHostGetReachability(self, has_been_resolved) };
241        ret.map(|ret| unsafe { CFRetained::retain(ret) })
242    }
243
244    #[doc(alias = "CFHostCancelInfoResolution")]
245    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
246    #[inline]
247    pub unsafe fn cancel_info_resolution(&self, info: CFHostInfoType) {
248        extern "C-unwind" {
249            fn CFHostCancelInfoResolution(the_host: &CFHost, info: CFHostInfoType);
250        }
251        unsafe { CFHostCancelInfoResolution(self, info) }
252    }
253
254    /// # Safety
255    ///
256    /// - `client_cb` must be implemented correctly.
257    /// - `client_context` must be a valid pointer or null.
258    #[doc(alias = "CFHostSetClient")]
259    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
260    #[inline]
261    pub unsafe fn set_client(
262        &self,
263        client_cb: CFHostClientCallBack,
264        client_context: *mut CFHostClientContext,
265    ) -> bool {
266        extern "C-unwind" {
267            fn CFHostSetClient(
268                the_host: &CFHost,
269                client_cb: CFHostClientCallBack,
270                client_context: *mut CFHostClientContext,
271            ) -> Boolean;
272        }
273        let ret = unsafe { CFHostSetClient(self, client_cb, client_context) };
274        ret != 0
275    }
276
277    /// # Safety
278    ///
279    /// `run_loop` possibly has additional threading requirements.
280    #[doc(alias = "CFHostScheduleWithRunLoop")]
281    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
282    #[inline]
283    pub unsafe fn schedule_with_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) {
284        extern "C-unwind" {
285            fn CFHostScheduleWithRunLoop(
286                the_host: &CFHost,
287                run_loop: &CFRunLoop,
288                run_loop_mode: &CFString,
289            );
290        }
291        unsafe { CFHostScheduleWithRunLoop(self, run_loop, run_loop_mode) }
292    }
293
294    /// # Safety
295    ///
296    /// `run_loop` possibly has additional threading requirements.
297    #[doc(alias = "CFHostUnscheduleFromRunLoop")]
298    #[deprecated = "Use Network framework instead, see deprecation notice in <CFNetwork/CFHost.h>"]
299    #[inline]
300    pub unsafe fn unschedule_from_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) {
301        extern "C-unwind" {
302            fn CFHostUnscheduleFromRunLoop(
303                the_host: &CFHost,
304                run_loop: &CFRunLoop,
305                run_loop_mode: &CFString,
306            );
307        }
308        unsafe { CFHostUnscheduleFromRunLoop(self, run_loop, run_loop_mode) }
309    }
310}
311
312#[deprecated = "renamed to `CFHost::with_name`"]
313#[inline]
314pub unsafe extern "C-unwind" fn CFHostCreateWithName(
315    allocator: Option<&CFAllocator>,
316    hostname: &CFString,
317) -> CFRetained<CFHost> {
318    extern "C-unwind" {
319        fn CFHostCreateWithName(
320            allocator: Option<&CFAllocator>,
321            hostname: &CFString,
322        ) -> Option<NonNull<CFHost>>;
323    }
324    let ret = unsafe { CFHostCreateWithName(allocator, hostname) };
325    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
326    unsafe { CFRetained::from_raw(ret) }
327}
328
329#[deprecated = "renamed to `CFHost::with_address`"]
330#[inline]
331pub unsafe extern "C-unwind" fn CFHostCreateWithAddress(
332    allocator: Option<&CFAllocator>,
333    addr: &CFData,
334) -> CFRetained<CFHost> {
335    extern "C-unwind" {
336        fn CFHostCreateWithAddress(
337            allocator: Option<&CFAllocator>,
338            addr: &CFData,
339        ) -> Option<NonNull<CFHost>>;
340    }
341    let ret = unsafe { CFHostCreateWithAddress(allocator, addr) };
342    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
343    unsafe { CFRetained::from_raw(ret) }
344}
345
346#[deprecated = "renamed to `CFHost::new_copy`"]
347#[inline]
348pub unsafe extern "C-unwind" fn CFHostCreateCopy(
349    alloc: Option<&CFAllocator>,
350    host: &CFHost,
351) -> CFRetained<CFHost> {
352    extern "C-unwind" {
353        fn CFHostCreateCopy(alloc: Option<&CFAllocator>, host: &CFHost) -> Option<NonNull<CFHost>>;
354    }
355    let ret = unsafe { CFHostCreateCopy(alloc, host) };
356    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
357    unsafe { CFRetained::from_raw(ret) }
358}
359
360#[deprecated = "renamed to `CFHost::start_info_resolution`"]
361#[inline]
362pub unsafe extern "C-unwind" fn CFHostStartInfoResolution(
363    the_host: &CFHost,
364    info: CFHostInfoType,
365    error: *mut CFStreamError,
366) -> bool {
367    extern "C-unwind" {
368        fn CFHostStartInfoResolution(
369            the_host: &CFHost,
370            info: CFHostInfoType,
371            error: *mut CFStreamError,
372        ) -> Boolean;
373    }
374    let ret = unsafe { CFHostStartInfoResolution(the_host, info, error) };
375    ret != 0
376}
377
378#[deprecated = "renamed to `CFHost::addressing`"]
379#[inline]
380pub unsafe extern "C-unwind" fn CFHostGetAddressing(
381    the_host: &CFHost,
382    has_been_resolved: *mut Boolean,
383) -> Option<CFRetained<CFArray>> {
384    extern "C-unwind" {
385        fn CFHostGetAddressing(
386            the_host: &CFHost,
387            has_been_resolved: *mut Boolean,
388        ) -> Option<NonNull<CFArray>>;
389    }
390    let ret = unsafe { CFHostGetAddressing(the_host, has_been_resolved) };
391    ret.map(|ret| unsafe { CFRetained::retain(ret) })
392}
393
394#[deprecated = "renamed to `CFHost::names`"]
395#[inline]
396pub unsafe extern "C-unwind" fn CFHostGetNames(
397    the_host: &CFHost,
398    has_been_resolved: *mut Boolean,
399) -> Option<CFRetained<CFArray>> {
400    extern "C-unwind" {
401        fn CFHostGetNames(
402            the_host: &CFHost,
403            has_been_resolved: *mut Boolean,
404        ) -> Option<NonNull<CFArray>>;
405    }
406    let ret = unsafe { CFHostGetNames(the_host, has_been_resolved) };
407    ret.map(|ret| unsafe { CFRetained::retain(ret) })
408}
409
410#[deprecated = "renamed to `CFHost::reachability`"]
411#[inline]
412pub unsafe extern "C-unwind" fn CFHostGetReachability(
413    the_host: &CFHost,
414    has_been_resolved: *mut Boolean,
415) -> Option<CFRetained<CFData>> {
416    extern "C-unwind" {
417        fn CFHostGetReachability(
418            the_host: &CFHost,
419            has_been_resolved: *mut Boolean,
420        ) -> Option<NonNull<CFData>>;
421    }
422    let ret = unsafe { CFHostGetReachability(the_host, has_been_resolved) };
423    ret.map(|ret| unsafe { CFRetained::retain(ret) })
424}
425
426extern "C-unwind" {
427    #[deprecated = "renamed to `CFHost::cancel_info_resolution`"]
428    pub fn CFHostCancelInfoResolution(the_host: &CFHost, info: CFHostInfoType);
429}
430
431#[deprecated = "renamed to `CFHost::set_client`"]
432#[inline]
433pub unsafe extern "C-unwind" fn CFHostSetClient(
434    the_host: &CFHost,
435    client_cb: CFHostClientCallBack,
436    client_context: *mut CFHostClientContext,
437) -> bool {
438    extern "C-unwind" {
439        fn CFHostSetClient(
440            the_host: &CFHost,
441            client_cb: CFHostClientCallBack,
442            client_context: *mut CFHostClientContext,
443        ) -> Boolean;
444    }
445    let ret = unsafe { CFHostSetClient(the_host, client_cb, client_context) };
446    ret != 0
447}
448
449extern "C-unwind" {
450    #[deprecated = "renamed to `CFHost::schedule_with_run_loop`"]
451    pub fn CFHostScheduleWithRunLoop(
452        the_host: &CFHost,
453        run_loop: &CFRunLoop,
454        run_loop_mode: &CFString,
455    );
456}
457
458extern "C-unwind" {
459    #[deprecated = "renamed to `CFHost::unschedule_from_run_loop`"]
460    pub fn CFHostUnscheduleFromRunLoop(
461        the_host: &CFHost,
462        run_loop: &CFRunLoop,
463        run_loop_mode: &CFString,
464    );
465}