objc2_core_foundation/generated/
CFPropertyList.rs1use core::ptr::NonNull;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct CFPropertyListMutabilityOptions(pub CFOptionFlags);
14bitflags::bitflags! {
15 impl CFPropertyListMutabilityOptions: CFOptionFlags {
16 #[doc(alias = "kCFPropertyListImmutable")]
17 const Immutable = 0;
18 #[doc(alias = "kCFPropertyListMutableContainers")]
19 const MutableContainers = 1<<0;
20 #[doc(alias = "kCFPropertyListMutableContainersAndLeaves")]
21 const MutableContainersAndLeaves = 1<<1;
22 }
23}
24
25#[cfg(feature = "objc2")]
26unsafe impl Encode for CFPropertyListMutabilityOptions {
27 const ENCODING: Encoding = CFOptionFlags::ENCODING;
28}
29
30#[cfg(feature = "objc2")]
31unsafe impl RefEncode for CFPropertyListMutabilityOptions {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35#[cfg(feature = "CFData")]
41#[deprecated = "Use CFPropertyListCreateWithData instead."]
42#[inline]
43pub unsafe extern "C-unwind" fn CFPropertyListCreateFromXMLData(
44 allocator: Option<&CFAllocator>,
45 xml_data: Option<&CFData>,
46 mutability_option: CFOptionFlags,
47 error_string: *mut *const CFString,
48) -> Option<CFRetained<CFPropertyList>> {
49 extern "C-unwind" {
50 fn CFPropertyListCreateFromXMLData(
51 allocator: Option<&CFAllocator>,
52 xml_data: Option<&CFData>,
53 mutability_option: CFOptionFlags,
54 error_string: *mut *const CFString,
55 ) -> Option<NonNull<CFPropertyList>>;
56 }
57 let ret = unsafe {
58 CFPropertyListCreateFromXMLData(allocator, xml_data, mutability_option, error_string)
59 };
60 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
61}
62
63#[cfg(feature = "CFData")]
69#[deprecated = "Use CFPropertyListCreateData instead."]
70#[inline]
71pub unsafe extern "C-unwind" fn CFPropertyListCreateXMLData(
72 allocator: Option<&CFAllocator>,
73 property_list: Option<&CFPropertyList>,
74) -> Option<CFRetained<CFData>> {
75 extern "C-unwind" {
76 fn CFPropertyListCreateXMLData(
77 allocator: Option<&CFAllocator>,
78 property_list: Option<&CFPropertyList>,
79 ) -> Option<NonNull<CFData>>;
80 }
81 let ret = unsafe { CFPropertyListCreateXMLData(allocator, property_list) };
82 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
83}
84
85#[inline]
91pub unsafe extern "C-unwind" fn CFPropertyListCreateDeepCopy(
92 allocator: Option<&CFAllocator>,
93 property_list: Option<&CFPropertyList>,
94 mutability_option: CFOptionFlags,
95) -> Option<CFRetained<CFPropertyList>> {
96 extern "C-unwind" {
97 fn CFPropertyListCreateDeepCopy(
98 allocator: Option<&CFAllocator>,
99 property_list: Option<&CFPropertyList>,
100 mutability_option: CFOptionFlags,
101 ) -> Option<NonNull<CFPropertyList>>;
102 }
103 let ret = unsafe { CFPropertyListCreateDeepCopy(allocator, property_list, mutability_option) };
104 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
105}
106
107#[repr(transparent)]
110#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
111pub struct CFPropertyListFormat(pub CFIndex);
112impl CFPropertyListFormat {
113 #[doc(alias = "kCFPropertyListOpenStepFormat")]
114 pub const OpenStepFormat: Self = Self(1);
115 #[doc(alias = "kCFPropertyListXMLFormat_v1_0")]
116 pub const XMLFormat_v1_0: Self = Self(100);
117 #[doc(alias = "kCFPropertyListBinaryFormat_v1_0")]
118 pub const BinaryFormat_v1_0: Self = Self(200);
119}
120
121#[cfg(feature = "objc2")]
122unsafe impl Encode for CFPropertyListFormat {
123 const ENCODING: Encoding = CFIndex::ENCODING;
124}
125
126#[cfg(feature = "objc2")]
127unsafe impl RefEncode for CFPropertyListFormat {
128 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
129}
130
131#[inline]
135pub unsafe extern "C-unwind" fn CFPropertyListIsValid(
136 plist: &CFPropertyList,
137 format: CFPropertyListFormat,
138) -> bool {
139 extern "C-unwind" {
140 fn CFPropertyListIsValid(plist: &CFPropertyList, format: CFPropertyListFormat) -> Boolean;
141 }
142 let ret = unsafe { CFPropertyListIsValid(plist, format) };
143 ret != 0
144}
145
146extern "C-unwind" {
147 #[cfg(feature = "CFStream")]
153 #[deprecated = "Use CFPropertyListWrite instead."]
154 pub fn CFPropertyListWriteToStream(
155 property_list: &CFPropertyList,
156 stream: Option<&CFWriteStream>,
157 format: CFPropertyListFormat,
158 error_string: *mut *const CFString,
159 ) -> CFIndex;
160}
161
162#[cfg(feature = "CFStream")]
169#[deprecated = "Use CFPropertyListCreateWithStream instead."]
170#[inline]
171pub unsafe extern "C-unwind" fn CFPropertyListCreateFromStream(
172 allocator: Option<&CFAllocator>,
173 stream: Option<&CFReadStream>,
174 stream_length: CFIndex,
175 mutability_option: CFOptionFlags,
176 format: *mut CFPropertyListFormat,
177 error_string: *mut *const CFString,
178) -> Option<CFRetained<CFPropertyList>> {
179 extern "C-unwind" {
180 fn CFPropertyListCreateFromStream(
181 allocator: Option<&CFAllocator>,
182 stream: Option<&CFReadStream>,
183 stream_length: CFIndex,
184 mutability_option: CFOptionFlags,
185 format: *mut CFPropertyListFormat,
186 error_string: *mut *const CFString,
187 ) -> Option<NonNull<CFPropertyList>>;
188 }
189 let ret = unsafe {
190 CFPropertyListCreateFromStream(
191 allocator,
192 stream,
193 stream_length,
194 mutability_option,
195 format,
196 error_string,
197 )
198 };
199 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
200}
201
202pub const kCFPropertyListReadCorruptError: CFIndex = 3840;
204pub const kCFPropertyListReadUnknownVersionError: CFIndex = 3841;
206pub const kCFPropertyListReadStreamError: CFIndex = 3842;
208pub const kCFPropertyListWriteStreamError: CFIndex = 3851;
210
211#[cfg(all(feature = "CFData", feature = "CFError"))]
218#[inline]
219pub unsafe extern "C-unwind" fn CFPropertyListCreateWithData(
220 allocator: Option<&CFAllocator>,
221 data: Option<&CFData>,
222 options: CFOptionFlags,
223 format: *mut CFPropertyListFormat,
224 error: *mut *mut CFError,
225) -> Option<CFRetained<CFPropertyList>> {
226 extern "C-unwind" {
227 fn CFPropertyListCreateWithData(
228 allocator: Option<&CFAllocator>,
229 data: Option<&CFData>,
230 options: CFOptionFlags,
231 format: *mut CFPropertyListFormat,
232 error: *mut *mut CFError,
233 ) -> Option<NonNull<CFPropertyList>>;
234 }
235 let ret = unsafe { CFPropertyListCreateWithData(allocator, data, options, format, error) };
236 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
237}
238
239#[cfg(all(feature = "CFError", feature = "CFStream"))]
246#[inline]
247pub unsafe extern "C-unwind" fn CFPropertyListCreateWithStream(
248 allocator: Option<&CFAllocator>,
249 stream: Option<&CFReadStream>,
250 stream_length: CFIndex,
251 options: CFOptionFlags,
252 format: *mut CFPropertyListFormat,
253 error: *mut *mut CFError,
254) -> Option<CFRetained<CFPropertyList>> {
255 extern "C-unwind" {
256 fn CFPropertyListCreateWithStream(
257 allocator: Option<&CFAllocator>,
258 stream: Option<&CFReadStream>,
259 stream_length: CFIndex,
260 options: CFOptionFlags,
261 format: *mut CFPropertyListFormat,
262 error: *mut *mut CFError,
263 ) -> Option<NonNull<CFPropertyList>>;
264 }
265 let ret = unsafe {
266 CFPropertyListCreateWithStream(allocator, stream, stream_length, options, format, error)
267 };
268 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
269}
270
271extern "C-unwind" {
272 #[cfg(all(feature = "CFError", feature = "CFStream"))]
278 pub fn CFPropertyListWrite(
279 property_list: &CFPropertyList,
280 stream: Option<&CFWriteStream>,
281 format: CFPropertyListFormat,
282 options: CFOptionFlags,
283 error: *mut *mut CFError,
284 ) -> CFIndex;
285}
286
287#[cfg(all(feature = "CFData", feature = "CFError"))]
294#[inline]
295pub unsafe extern "C-unwind" fn CFPropertyListCreateData(
296 allocator: Option<&CFAllocator>,
297 property_list: Option<&CFPropertyList>,
298 format: CFPropertyListFormat,
299 options: CFOptionFlags,
300 error: *mut *mut CFError,
301) -> Option<CFRetained<CFData>> {
302 extern "C-unwind" {
303 fn CFPropertyListCreateData(
304 allocator: Option<&CFAllocator>,
305 property_list: Option<&CFPropertyList>,
306 format: CFPropertyListFormat,
307 options: CFOptionFlags,
308 error: *mut *mut CFError,
309 ) -> Option<NonNull<CFData>>;
310 }
311 let ret = unsafe { CFPropertyListCreateData(allocator, property_list, format, options, error) };
312 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
313}