objc2_foundation/generated/
NSPropertyList.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8#[repr(transparent)]
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12pub struct NSPropertyListMutabilityOptions(pub NSUInteger);
13bitflags::bitflags! {
14 impl NSPropertyListMutabilityOptions: NSUInteger {
15 #[doc(alias = "NSPropertyListImmutable")]
16 const Immutable = 0;
17 #[doc(alias = "NSPropertyListMutableContainers")]
18 const MutableContainers = 1;
19 #[doc(alias = "NSPropertyListMutableContainersAndLeaves")]
20 const MutableContainersAndLeaves = 2;
21 }
22}
23
24unsafe impl Encode for NSPropertyListMutabilityOptions {
25 const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSPropertyListMutabilityOptions {
29 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct NSPropertyListFormat(pub NSUInteger);
37impl NSPropertyListFormat {
38 #[doc(alias = "NSPropertyListOpenStepFormat")]
39 pub const OpenStepFormat: Self = Self(1);
40 #[doc(alias = "NSPropertyListXMLFormat_v1_0")]
41 pub const XMLFormat_v1_0: Self = Self(100);
42 #[doc(alias = "NSPropertyListBinaryFormat_v1_0")]
43 pub const BinaryFormat_v1_0: Self = Self(200);
44}
45
46unsafe impl Encode for NSPropertyListFormat {
47 const ENCODING: Encoding = NSUInteger::ENCODING;
48}
49
50unsafe impl RefEncode for NSPropertyListFormat {
51 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54pub type NSPropertyListReadOptions = NSPropertyListMutabilityOptions;
56
57pub type NSPropertyListWriteOptions = NSUInteger;
59
60extern_class!(
61 #[unsafe(super(NSObject))]
63 #[derive(Debug, PartialEq, Eq, Hash)]
64 pub struct NSPropertyListSerialization;
65);
66
67extern_conformance!(
68 unsafe impl NSObjectProtocol for NSPropertyListSerialization {}
69);
70
71impl NSPropertyListSerialization {
72 extern_methods!(
73 #[unsafe(method(propertyList:isValidForFormat:))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn propertyList_isValidForFormat(
79 plist: &AnyObject,
80 format: NSPropertyListFormat,
81 ) -> bool;
82
83 #[cfg(all(feature = "NSData", feature = "NSError"))]
84 #[unsafe(method(dataWithPropertyList:format:options:error:_))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn dataWithPropertyList_format_options_error(
90 plist: &AnyObject,
91 format: NSPropertyListFormat,
92 opt: NSPropertyListWriteOptions,
93 ) -> Result<Retained<NSData>, Retained<NSError>>;
94
95 #[cfg(all(feature = "NSData", feature = "NSError"))]
96 #[unsafe(method(propertyListWithData:options:format:error:_))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn propertyListWithData_options_format_error(
102 data: &NSData,
103 opt: NSPropertyListReadOptions,
104 format: *mut NSPropertyListFormat,
105 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
106
107 #[cfg(all(feature = "NSError", feature = "NSStream"))]
108 #[unsafe(method(propertyListWithStream:options:format:error:_))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn propertyListWithStream_options_format_error(
114 stream: &NSInputStream,
115 opt: NSPropertyListReadOptions,
116 format: *mut NSPropertyListFormat,
117 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
118
119 #[cfg(all(feature = "NSData", feature = "NSString"))]
120 #[deprecated = "Use dataWithPropertyList:format:options:error: instead."]
125 #[unsafe(method(dataFromPropertyList:format:errorDescription:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn dataFromPropertyList_format_errorDescription(
128 plist: &AnyObject,
129 format: NSPropertyListFormat,
130 error_string: *mut *mut NSString,
131 ) -> Option<Retained<NSData>>;
132
133 #[cfg(all(feature = "NSData", feature = "NSString"))]
134 #[deprecated = "Use propertyListWithData:options:format:error: instead."]
139 #[unsafe(method(propertyListFromData:mutabilityOption:format:errorDescription:))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn propertyListFromData_mutabilityOption_format_errorDescription(
142 data: &NSData,
143 opt: NSPropertyListMutabilityOptions,
144 format: *mut NSPropertyListFormat,
145 error_string: *mut *mut NSString,
146 ) -> Option<Retained<AnyObject>>;
147 );
148}
149
150impl NSPropertyListSerialization {
152 extern_methods!(
153 #[unsafe(method(init))]
154 #[unsafe(method_family = init)]
155 pub fn init(this: Allocated<Self>) -> Retained<Self>;
156
157 #[unsafe(method(new))]
158 #[unsafe(method_family = new)]
159 pub fn new() -> Retained<Self>;
160 );
161}
162
163impl DefaultRetained for NSPropertyListSerialization {
164 #[inline]
165 fn default_retained() -> Retained<Self> {
166 Self::new()
167 }
168}