objc2_cf_network/generated/
CFHTTPAuthentication.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/cfhttpauthentication?language=objc)
14#[doc(alias = "CFHTTPAuthenticationRef")]
15#[repr(C)]
16pub struct CFHTTPAuthentication {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22    unsafe impl CFHTTPAuthentication {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26    unsafe impl RefEncode<"_CFHTTPAuthentication"> for CFHTTPAuthentication {}
27);
28
29/// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/cfstreamerrorhttpauthentication?language=objc)
30// NS_ENUM
31#[repr(transparent)]
32#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
33pub struct CFStreamErrorHTTPAuthentication(pub c_int);
34impl CFStreamErrorHTTPAuthentication {
35    #[doc(alias = "kCFStreamErrorHTTPAuthenticationTypeUnsupported")]
36    pub const TypeUnsupported: Self = Self(-1000);
37    #[doc(alias = "kCFStreamErrorHTTPAuthenticationBadUserName")]
38    pub const BadUserName: Self = Self(-1001);
39    #[doc(alias = "kCFStreamErrorHTTPAuthenticationBadPassword")]
40    pub const BadPassword: Self = Self(-1002);
41}
42
43#[cfg(feature = "objc2")]
44unsafe impl Encode for CFStreamErrorHTTPAuthentication {
45    const ENCODING: Encoding = c_int::ENCODING;
46}
47
48#[cfg(feature = "objc2")]
49unsafe impl RefEncode for CFStreamErrorHTTPAuthentication {
50    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
51}
52
53extern "C" {
54    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfhttpauthenticationusername?language=objc)
55    pub static kCFHTTPAuthenticationUsername: &'static CFString;
56}
57
58extern "C" {
59    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfhttpauthenticationpassword?language=objc)
60    pub static kCFHTTPAuthenticationPassword: &'static CFString;
61}
62
63extern "C" {
64    /// [Apple's documentation](https://developer.apple.com/documentation/cfnetwork/kcfhttpauthenticationaccountdomain?language=objc)
65    pub static kCFHTTPAuthenticationAccountDomain: &'static CFString;
66}
67
68unsafe impl ConcreteType for CFHTTPAuthentication {
69    #[doc(alias = "CFHTTPAuthenticationGetTypeID")]
70    #[inline]
71    fn type_id() -> CFTypeID {
72        extern "C-unwind" {
73            fn CFHTTPAuthenticationGetTypeID() -> CFTypeID;
74        }
75        unsafe { CFHTTPAuthenticationGetTypeID() }
76    }
77}
78
79impl CFHTTPAuthentication {
80    #[doc(alias = "CFHTTPAuthenticationCreateFromResponse")]
81    #[cfg(feature = "CFHTTPMessage")]
82    #[inline]
83    pub unsafe fn from_response(
84        alloc: Option<&CFAllocator>,
85        response: &CFHTTPMessage,
86    ) -> CFRetained<CFHTTPAuthentication> {
87        extern "C-unwind" {
88            fn CFHTTPAuthenticationCreateFromResponse(
89                alloc: Option<&CFAllocator>,
90                response: &CFHTTPMessage,
91            ) -> Option<NonNull<CFHTTPAuthentication>>;
92        }
93        let ret = unsafe { CFHTTPAuthenticationCreateFromResponse(alloc, response) };
94        let ret =
95            ret.expect("function was marked as returning non-null, but actually returned NULL");
96        unsafe { CFRetained::from_raw(ret) }
97    }
98
99    /// # Safety
100    ///
101    /// `error` must be a valid pointer or null.
102    #[doc(alias = "CFHTTPAuthenticationIsValid")]
103    #[inline]
104    pub unsafe fn is_valid(&self, error: *mut CFStreamError) -> bool {
105        extern "C-unwind" {
106            fn CFHTTPAuthenticationIsValid(
107                auth: &CFHTTPAuthentication,
108                error: *mut CFStreamError,
109            ) -> Boolean;
110        }
111        let ret = unsafe { CFHTTPAuthenticationIsValid(self, error) };
112        ret != 0
113    }
114
115    #[doc(alias = "CFHTTPAuthenticationAppliesToRequest")]
116    #[cfg(feature = "CFHTTPMessage")]
117    #[inline]
118    pub unsafe fn applies_to_request(&self, request: &CFHTTPMessage) -> bool {
119        extern "C-unwind" {
120            fn CFHTTPAuthenticationAppliesToRequest(
121                auth: &CFHTTPAuthentication,
122                request: &CFHTTPMessage,
123            ) -> Boolean;
124        }
125        let ret = unsafe { CFHTTPAuthenticationAppliesToRequest(self, request) };
126        ret != 0
127    }
128
129    #[doc(alias = "CFHTTPAuthenticationRequiresOrderedRequests")]
130    #[inline]
131    pub unsafe fn requires_ordered_requests(&self) -> bool {
132        extern "C-unwind" {
133            fn CFHTTPAuthenticationRequiresOrderedRequests(auth: &CFHTTPAuthentication) -> Boolean;
134        }
135        let ret = unsafe { CFHTTPAuthenticationRequiresOrderedRequests(self) };
136        ret != 0
137    }
138}
139
140#[cfg(feature = "CFHTTPMessage")]
141impl CFHTTPMessage {
142    /// # Safety
143    ///
144    /// `error` must be a valid pointer or null.
145    #[doc(alias = "CFHTTPMessageApplyCredentials")]
146    #[cfg(feature = "CFHTTPMessage")]
147    #[inline]
148    pub unsafe fn apply_credentials(
149        &self,
150        auth: &CFHTTPAuthentication,
151        username: Option<&CFString>,
152        password: Option<&CFString>,
153        error: *mut CFStreamError,
154    ) -> bool {
155        extern "C-unwind" {
156            fn CFHTTPMessageApplyCredentials(
157                request: &CFHTTPMessage,
158                auth: &CFHTTPAuthentication,
159                username: Option<&CFString>,
160                password: Option<&CFString>,
161                error: *mut CFStreamError,
162            ) -> Boolean;
163        }
164        let ret = unsafe { CFHTTPMessageApplyCredentials(self, auth, username, password, error) };
165        ret != 0
166    }
167
168    /// # Safety
169    ///
170    /// - `dict` generics must be of the correct type.
171    /// - `error` must be a valid pointer or null.
172    #[doc(alias = "CFHTTPMessageApplyCredentialDictionary")]
173    #[cfg(feature = "CFHTTPMessage")]
174    #[inline]
175    pub unsafe fn apply_credential_dictionary(
176        &self,
177        auth: &CFHTTPAuthentication,
178        dict: &CFDictionary,
179        error: *mut CFStreamError,
180    ) -> bool {
181        extern "C-unwind" {
182            fn CFHTTPMessageApplyCredentialDictionary(
183                request: &CFHTTPMessage,
184                auth: &CFHTTPAuthentication,
185                dict: &CFDictionary,
186                error: *mut CFStreamError,
187            ) -> Boolean;
188        }
189        let ret = unsafe { CFHTTPMessageApplyCredentialDictionary(self, auth, dict, error) };
190        ret != 0
191    }
192}
193
194impl CFHTTPAuthentication {
195    #[doc(alias = "CFHTTPAuthenticationCopyRealm")]
196    #[inline]
197    pub unsafe fn realm(&self) -> CFRetained<CFString> {
198        extern "C-unwind" {
199            fn CFHTTPAuthenticationCopyRealm(
200                auth: &CFHTTPAuthentication,
201            ) -> Option<NonNull<CFString>>;
202        }
203        let ret = unsafe { CFHTTPAuthenticationCopyRealm(self) };
204        let ret =
205            ret.expect("function was marked as returning non-null, but actually returned NULL");
206        unsafe { CFRetained::from_raw(ret) }
207    }
208
209    #[doc(alias = "CFHTTPAuthenticationCopyDomains")]
210    #[inline]
211    pub unsafe fn domains(&self) -> CFRetained<CFArray> {
212        extern "C-unwind" {
213            fn CFHTTPAuthenticationCopyDomains(
214                auth: &CFHTTPAuthentication,
215            ) -> Option<NonNull<CFArray>>;
216        }
217        let ret = unsafe { CFHTTPAuthenticationCopyDomains(self) };
218        let ret =
219            ret.expect("function was marked as returning non-null, but actually returned NULL");
220        unsafe { CFRetained::from_raw(ret) }
221    }
222
223    #[doc(alias = "CFHTTPAuthenticationCopyMethod")]
224    #[inline]
225    pub unsafe fn method(&self) -> CFRetained<CFString> {
226        extern "C-unwind" {
227            fn CFHTTPAuthenticationCopyMethod(
228                auth: &CFHTTPAuthentication,
229            ) -> Option<NonNull<CFString>>;
230        }
231        let ret = unsafe { CFHTTPAuthenticationCopyMethod(self) };
232        let ret =
233            ret.expect("function was marked as returning non-null, but actually returned NULL");
234        unsafe { CFRetained::from_raw(ret) }
235    }
236
237    #[doc(alias = "CFHTTPAuthenticationRequiresUserNameAndPassword")]
238    #[inline]
239    pub unsafe fn requires_user_name_and_password(&self) -> bool {
240        extern "C-unwind" {
241            fn CFHTTPAuthenticationRequiresUserNameAndPassword(
242                auth: &CFHTTPAuthentication,
243            ) -> Boolean;
244        }
245        let ret = unsafe { CFHTTPAuthenticationRequiresUserNameAndPassword(self) };
246        ret != 0
247    }
248
249    #[doc(alias = "CFHTTPAuthenticationRequiresAccountDomain")]
250    #[inline]
251    pub unsafe fn requires_account_domain(&self) -> bool {
252        extern "C-unwind" {
253            fn CFHTTPAuthenticationRequiresAccountDomain(auth: &CFHTTPAuthentication) -> Boolean;
254        }
255        let ret = unsafe { CFHTTPAuthenticationRequiresAccountDomain(self) };
256        ret != 0
257    }
258}
259
260#[cfg(feature = "CFHTTPMessage")]
261#[deprecated = "renamed to `CFHTTPAuthentication::from_response`"]
262#[inline]
263pub unsafe extern "C-unwind" fn CFHTTPAuthenticationCreateFromResponse(
264    alloc: Option<&CFAllocator>,
265    response: &CFHTTPMessage,
266) -> CFRetained<CFHTTPAuthentication> {
267    extern "C-unwind" {
268        fn CFHTTPAuthenticationCreateFromResponse(
269            alloc: Option<&CFAllocator>,
270            response: &CFHTTPMessage,
271        ) -> Option<NonNull<CFHTTPAuthentication>>;
272    }
273    let ret = unsafe { CFHTTPAuthenticationCreateFromResponse(alloc, response) };
274    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
275    unsafe { CFRetained::from_raw(ret) }
276}
277
278#[deprecated = "renamed to `CFHTTPAuthentication::is_valid`"]
279#[inline]
280pub unsafe extern "C-unwind" fn CFHTTPAuthenticationIsValid(
281    auth: &CFHTTPAuthentication,
282    error: *mut CFStreamError,
283) -> bool {
284    extern "C-unwind" {
285        fn CFHTTPAuthenticationIsValid(
286            auth: &CFHTTPAuthentication,
287            error: *mut CFStreamError,
288        ) -> Boolean;
289    }
290    let ret = unsafe { CFHTTPAuthenticationIsValid(auth, error) };
291    ret != 0
292}
293
294#[cfg(feature = "CFHTTPMessage")]
295#[deprecated = "renamed to `CFHTTPAuthentication::applies_to_request`"]
296#[inline]
297pub unsafe extern "C-unwind" fn CFHTTPAuthenticationAppliesToRequest(
298    auth: &CFHTTPAuthentication,
299    request: &CFHTTPMessage,
300) -> bool {
301    extern "C-unwind" {
302        fn CFHTTPAuthenticationAppliesToRequest(
303            auth: &CFHTTPAuthentication,
304            request: &CFHTTPMessage,
305        ) -> Boolean;
306    }
307    let ret = unsafe { CFHTTPAuthenticationAppliesToRequest(auth, request) };
308    ret != 0
309}
310
311#[deprecated = "renamed to `CFHTTPAuthentication::requires_ordered_requests`"]
312#[inline]
313pub unsafe extern "C-unwind" fn CFHTTPAuthenticationRequiresOrderedRequests(
314    auth: &CFHTTPAuthentication,
315) -> bool {
316    extern "C-unwind" {
317        fn CFHTTPAuthenticationRequiresOrderedRequests(auth: &CFHTTPAuthentication) -> Boolean;
318    }
319    let ret = unsafe { CFHTTPAuthenticationRequiresOrderedRequests(auth) };
320    ret != 0
321}
322
323#[cfg(feature = "CFHTTPMessage")]
324#[deprecated = "renamed to `CFHTTPMessage::apply_credentials`"]
325#[inline]
326pub unsafe extern "C-unwind" fn CFHTTPMessageApplyCredentials(
327    request: &CFHTTPMessage,
328    auth: &CFHTTPAuthentication,
329    username: Option<&CFString>,
330    password: Option<&CFString>,
331    error: *mut CFStreamError,
332) -> bool {
333    extern "C-unwind" {
334        fn CFHTTPMessageApplyCredentials(
335            request: &CFHTTPMessage,
336            auth: &CFHTTPAuthentication,
337            username: Option<&CFString>,
338            password: Option<&CFString>,
339            error: *mut CFStreamError,
340        ) -> Boolean;
341    }
342    let ret = unsafe { CFHTTPMessageApplyCredentials(request, auth, username, password, error) };
343    ret != 0
344}
345
346#[cfg(feature = "CFHTTPMessage")]
347#[deprecated = "renamed to `CFHTTPMessage::apply_credential_dictionary`"]
348#[inline]
349pub unsafe extern "C-unwind" fn CFHTTPMessageApplyCredentialDictionary(
350    request: &CFHTTPMessage,
351    auth: &CFHTTPAuthentication,
352    dict: &CFDictionary,
353    error: *mut CFStreamError,
354) -> bool {
355    extern "C-unwind" {
356        fn CFHTTPMessageApplyCredentialDictionary(
357            request: &CFHTTPMessage,
358            auth: &CFHTTPAuthentication,
359            dict: &CFDictionary,
360            error: *mut CFStreamError,
361        ) -> Boolean;
362    }
363    let ret = unsafe { CFHTTPMessageApplyCredentialDictionary(request, auth, dict, error) };
364    ret != 0
365}
366
367#[deprecated = "renamed to `CFHTTPAuthentication::realm`"]
368#[inline]
369pub unsafe extern "C-unwind" fn CFHTTPAuthenticationCopyRealm(
370    auth: &CFHTTPAuthentication,
371) -> CFRetained<CFString> {
372    extern "C-unwind" {
373        fn CFHTTPAuthenticationCopyRealm(auth: &CFHTTPAuthentication) -> Option<NonNull<CFString>>;
374    }
375    let ret = unsafe { CFHTTPAuthenticationCopyRealm(auth) };
376    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
377    unsafe { CFRetained::from_raw(ret) }
378}
379
380#[deprecated = "renamed to `CFHTTPAuthentication::domains`"]
381#[inline]
382pub unsafe extern "C-unwind" fn CFHTTPAuthenticationCopyDomains(
383    auth: &CFHTTPAuthentication,
384) -> CFRetained<CFArray> {
385    extern "C-unwind" {
386        fn CFHTTPAuthenticationCopyDomains(auth: &CFHTTPAuthentication)
387            -> Option<NonNull<CFArray>>;
388    }
389    let ret = unsafe { CFHTTPAuthenticationCopyDomains(auth) };
390    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
391    unsafe { CFRetained::from_raw(ret) }
392}
393
394#[deprecated = "renamed to `CFHTTPAuthentication::method`"]
395#[inline]
396pub unsafe extern "C-unwind" fn CFHTTPAuthenticationCopyMethod(
397    auth: &CFHTTPAuthentication,
398) -> CFRetained<CFString> {
399    extern "C-unwind" {
400        fn CFHTTPAuthenticationCopyMethod(auth: &CFHTTPAuthentication)
401            -> Option<NonNull<CFString>>;
402    }
403    let ret = unsafe { CFHTTPAuthenticationCopyMethod(auth) };
404    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
405    unsafe { CFRetained::from_raw(ret) }
406}
407
408#[deprecated = "renamed to `CFHTTPAuthentication::requires_user_name_and_password`"]
409#[inline]
410pub unsafe extern "C-unwind" fn CFHTTPAuthenticationRequiresUserNameAndPassword(
411    auth: &CFHTTPAuthentication,
412) -> bool {
413    extern "C-unwind" {
414        fn CFHTTPAuthenticationRequiresUserNameAndPassword(auth: &CFHTTPAuthentication) -> Boolean;
415    }
416    let ret = unsafe { CFHTTPAuthenticationRequiresUserNameAndPassword(auth) };
417    ret != 0
418}
419
420#[deprecated = "renamed to `CFHTTPAuthentication::requires_account_domain`"]
421#[inline]
422pub unsafe extern "C-unwind" fn CFHTTPAuthenticationRequiresAccountDomain(
423    auth: &CFHTTPAuthentication,
424) -> bool {
425    extern "C-unwind" {
426        fn CFHTTPAuthenticationRequiresAccountDomain(auth: &CFHTTPAuthentication) -> Boolean;
427    }
428    let ret = unsafe { CFHTTPAuthenticationRequiresAccountDomain(auth) };
429    ret != 0
430}