objc2_core_foundation/generated/
CFURLAccess.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[cfg(feature = "CFURL")]
10impl CFURL {
11    /// # Safety
12    ///
13    /// - `alloc` might not allow `None`.
14    /// - `url` might not allow `None`.
15    /// - `resource_data` must be a valid pointer.
16    /// - `properties` must be a valid pointer.
17    /// - `desired_properties` generic must be of the correct type.
18    /// - `desired_properties` might not allow `None`.
19    /// - `error_code` must be a valid pointer.
20    #[doc(alias = "CFURLCreateDataAndPropertiesFromResource")]
21    #[cfg(all(
22        feature = "CFArray",
23        feature = "CFData",
24        feature = "CFDictionary",
25        feature = "CFURL"
26    ))]
27    #[deprecated = "For resource data, use the CFReadStream API. For file resource properties, use CFURLCopyResourcePropertiesForKeys."]
28    #[inline]
29    pub unsafe fn new_data_and_properties_from_resource(
30        alloc: Option<&CFAllocator>,
31        url: Option<&CFURL>,
32        resource_data: *mut *const CFData,
33        properties: *mut *const CFDictionary,
34        desired_properties: Option<&CFArray>,
35        error_code: *mut i32,
36    ) -> bool {
37        extern "C-unwind" {
38            fn CFURLCreateDataAndPropertiesFromResource(
39                alloc: Option<&CFAllocator>,
40                url: Option<&CFURL>,
41                resource_data: *mut *const CFData,
42                properties: *mut *const CFDictionary,
43                desired_properties: Option<&CFArray>,
44                error_code: *mut i32,
45            ) -> Boolean;
46        }
47        let ret = unsafe {
48            CFURLCreateDataAndPropertiesFromResource(
49                alloc,
50                url,
51                resource_data,
52                properties,
53                desired_properties,
54                error_code,
55            )
56        };
57        ret != 0
58    }
59
60    /// # Safety
61    ///
62    /// - `data_to_write` might not allow `None`.
63    /// - `properties_to_write` generics must be of the correct type.
64    /// - `properties_to_write` might not allow `None`.
65    /// - `error_code` must be a valid pointer.
66    #[doc(alias = "CFURLWriteDataAndPropertiesToResource")]
67    #[cfg(all(feature = "CFData", feature = "CFDictionary", feature = "CFURL"))]
68    #[deprecated = "For resource data, use the CFWriteStream API. For file resource properties, use CFURLSetResourcePropertiesForKeys."]
69    #[inline]
70    pub unsafe fn write_data_and_properties_to_resource(
71        &self,
72        data_to_write: Option<&CFData>,
73        properties_to_write: Option<&CFDictionary>,
74        error_code: *mut i32,
75    ) -> bool {
76        extern "C-unwind" {
77            fn CFURLWriteDataAndPropertiesToResource(
78                url: &CFURL,
79                data_to_write: Option<&CFData>,
80                properties_to_write: Option<&CFDictionary>,
81                error_code: *mut i32,
82            ) -> Boolean;
83        }
84        let ret = unsafe {
85            CFURLWriteDataAndPropertiesToResource(
86                self,
87                data_to_write,
88                properties_to_write,
89                error_code,
90            )
91        };
92        ret != 0
93    }
94
95    /// # Safety
96    ///
97    /// `error_code` must be a valid pointer.
98    #[doc(alias = "CFURLDestroyResource")]
99    #[cfg(feature = "CFURL")]
100    #[deprecated = "Use CFURLGetFileSystemRepresentation and removefile(3) instead."]
101    #[inline]
102    pub unsafe fn destroy_resource(&self, error_code: *mut i32) -> bool {
103        extern "C-unwind" {
104            fn CFURLDestroyResource(url: &CFURL, error_code: *mut i32) -> Boolean;
105        }
106        let ret = unsafe { CFURLDestroyResource(self, error_code) };
107        ret != 0
108    }
109
110    /// # Safety
111    ///
112    /// - `alloc` might not allow `None`.
113    /// - `url` might not allow `None`.
114    /// - `property` might not allow `None`.
115    /// - `error_code` must be a valid pointer.
116    #[doc(alias = "CFURLCreatePropertyFromResource")]
117    #[cfg(feature = "CFURL")]
118    #[deprecated = "For file resource properties, use CFURLCopyResourcePropertyForKey."]
119    #[inline]
120    pub unsafe fn new_property_from_resource(
121        alloc: Option<&CFAllocator>,
122        url: Option<&CFURL>,
123        property: Option<&CFString>,
124        error_code: *mut i32,
125    ) -> Option<CFRetained<CFType>> {
126        extern "C-unwind" {
127            fn CFURLCreatePropertyFromResource(
128                alloc: Option<&CFAllocator>,
129                url: Option<&CFURL>,
130                property: Option<&CFString>,
131                error_code: *mut i32,
132            ) -> Option<NonNull<CFType>>;
133        }
134        let ret = unsafe { CFURLCreatePropertyFromResource(alloc, url, property, error_code) };
135        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
136    }
137}
138
139/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfurlerror?language=objc)
140// NS_ENUM
141#[deprecated = "Use CFError codes instead"]
142#[repr(transparent)]
143#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
144pub struct CFURLError(pub CFIndex);
145impl CFURLError {
146    #[doc(alias = "kCFURLUnknownError")]
147    #[deprecated = "Use CFError codes instead"]
148    pub const UnknownError: Self = Self(-10);
149    #[doc(alias = "kCFURLUnknownSchemeError")]
150    #[deprecated = "Use CFError codes instead"]
151    pub const UnknownSchemeError: Self = Self(-11);
152    #[doc(alias = "kCFURLResourceNotFoundError")]
153    #[deprecated = "Use CFError codes instead"]
154    pub const ResourceNotFoundError: Self = Self(-12);
155    #[doc(alias = "kCFURLResourceAccessViolationError")]
156    #[deprecated = "Use CFError codes instead"]
157    pub const ResourceAccessViolationError: Self = Self(-13);
158    #[doc(alias = "kCFURLRemoteHostUnavailableError")]
159    #[deprecated = "Use CFError codes instead"]
160    pub const RemoteHostUnavailableError: Self = Self(-14);
161    #[doc(alias = "kCFURLImproperArgumentsError")]
162    #[deprecated = "Use CFError codes instead"]
163    pub const ImproperArgumentsError: Self = Self(-15);
164    #[doc(alias = "kCFURLUnknownPropertyKeyError")]
165    #[deprecated = "Use CFError codes instead"]
166    pub const UnknownPropertyKeyError: Self = Self(-16);
167    #[doc(alias = "kCFURLPropertyKeyUnavailableError")]
168    #[deprecated = "Use CFError codes instead"]
169    pub const PropertyKeyUnavailableError: Self = Self(-17);
170    #[doc(alias = "kCFURLTimeoutError")]
171    #[deprecated = "Use CFError codes instead"]
172    pub const TimeoutError: Self = Self(-18);
173}
174
175#[cfg(feature = "objc2")]
176unsafe impl Encode for CFURLError {
177    const ENCODING: Encoding = CFIndex::ENCODING;
178}
179
180#[cfg(feature = "objc2")]
181unsafe impl RefEncode for CFURLError {
182    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
183}
184
185extern "C" {
186    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlfileexists?language=objc)
187    #[deprecated = "Use CFURLResourceIsReachable instead."]
188    pub static kCFURLFileExists: Option<&'static CFString>;
189}
190
191extern "C" {
192    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlfiledirectorycontents?language=objc)
193    #[deprecated = "Use the CFURLEnumerator API instead."]
194    pub static kCFURLFileDirectoryContents: Option<&'static CFString>;
195}
196
197extern "C" {
198    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlfilelength?language=objc)
199    #[deprecated = "Use CFURLCopyResourcePropertyForKey with kCFURLFileSizeKey instead."]
200    pub static kCFURLFileLength: Option<&'static CFString>;
201}
202
203extern "C" {
204    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlfilelastmodificationtime?language=objc)
205    #[deprecated = "Use CFURLCopyResourcePropertyForKey with kCFURLContentModificationDateKey instead."]
206    pub static kCFURLFileLastModificationTime: Option<&'static CFString>;
207}
208
209extern "C" {
210    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlfileposixmode?language=objc)
211    #[deprecated = "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."]
212    pub static kCFURLFilePOSIXMode: Option<&'static CFString>;
213}
214
215extern "C" {
216    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlfileownerid?language=objc)
217    #[deprecated = "Use CFURLCopyResourcePropertyForKey with kCFURLFileSecurityKey and then the CFFileSecurity API instead."]
218    pub static kCFURLFileOwnerID: Option<&'static CFString>;
219}
220
221extern "C" {
222    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlhttpstatuscode?language=objc)
223    #[deprecated = "Use NSHTTPURLResponse methods instead."]
224    pub static kCFURLHTTPStatusCode: Option<&'static CFString>;
225}
226
227extern "C" {
228    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfurlhttpstatusline?language=objc)
229    #[deprecated = "Use NSHTTPURLResponse methods instead."]
230    pub static kCFURLHTTPStatusLine: Option<&'static CFString>;
231}
232
233#[cfg(all(
234    feature = "CFArray",
235    feature = "CFData",
236    feature = "CFDictionary",
237    feature = "CFURL"
238))]
239#[deprecated = "renamed to `CFURL::new_data_and_properties_from_resource`"]
240#[inline]
241pub unsafe extern "C-unwind" fn CFURLCreateDataAndPropertiesFromResource(
242    alloc: Option<&CFAllocator>,
243    url: Option<&CFURL>,
244    resource_data: *mut *const CFData,
245    properties: *mut *const CFDictionary,
246    desired_properties: Option<&CFArray>,
247    error_code: *mut i32,
248) -> bool {
249    extern "C-unwind" {
250        fn CFURLCreateDataAndPropertiesFromResource(
251            alloc: Option<&CFAllocator>,
252            url: Option<&CFURL>,
253            resource_data: *mut *const CFData,
254            properties: *mut *const CFDictionary,
255            desired_properties: Option<&CFArray>,
256            error_code: *mut i32,
257        ) -> Boolean;
258    }
259    let ret = unsafe {
260        CFURLCreateDataAndPropertiesFromResource(
261            alloc,
262            url,
263            resource_data,
264            properties,
265            desired_properties,
266            error_code,
267        )
268    };
269    ret != 0
270}
271
272#[cfg(all(feature = "CFData", feature = "CFDictionary", feature = "CFURL"))]
273#[deprecated = "renamed to `CFURL::write_data_and_properties_to_resource`"]
274#[inline]
275pub unsafe extern "C-unwind" fn CFURLWriteDataAndPropertiesToResource(
276    url: &CFURL,
277    data_to_write: Option<&CFData>,
278    properties_to_write: Option<&CFDictionary>,
279    error_code: *mut i32,
280) -> bool {
281    extern "C-unwind" {
282        fn CFURLWriteDataAndPropertiesToResource(
283            url: &CFURL,
284            data_to_write: Option<&CFData>,
285            properties_to_write: Option<&CFDictionary>,
286            error_code: *mut i32,
287        ) -> Boolean;
288    }
289    let ret = unsafe {
290        CFURLWriteDataAndPropertiesToResource(url, data_to_write, properties_to_write, error_code)
291    };
292    ret != 0
293}
294
295#[cfg(feature = "CFURL")]
296#[deprecated = "renamed to `CFURL::destroy_resource`"]
297#[inline]
298pub unsafe extern "C-unwind" fn CFURLDestroyResource(url: &CFURL, error_code: *mut i32) -> bool {
299    extern "C-unwind" {
300        fn CFURLDestroyResource(url: &CFURL, error_code: *mut i32) -> Boolean;
301    }
302    let ret = unsafe { CFURLDestroyResource(url, error_code) };
303    ret != 0
304}
305
306#[cfg(feature = "CFURL")]
307#[deprecated = "renamed to `CFURL::new_property_from_resource`"]
308#[inline]
309pub unsafe extern "C-unwind" fn CFURLCreatePropertyFromResource(
310    alloc: Option<&CFAllocator>,
311    url: Option<&CFURL>,
312    property: Option<&CFString>,
313    error_code: *mut i32,
314) -> Option<CFRetained<CFType>> {
315    extern "C-unwind" {
316        fn CFURLCreatePropertyFromResource(
317            alloc: Option<&CFAllocator>,
318            url: Option<&CFURL>,
319            property: Option<&CFString>,
320            error_code: *mut i32,
321        ) -> Option<NonNull<CFType>>;
322    }
323    let ret = unsafe { CFURLCreatePropertyFromResource(alloc, url, property, error_code) };
324    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
325}