objc2_foundation/generated/
NSArchiver.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10    /// **********        Archiving: Writing    ***************
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsarchiver?language=objc)
13    #[unsafe(super(NSCoder, NSObject))]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    #[cfg(feature = "NSCoder")]
16    #[deprecated = "Use NSKeyedArchiver instead"]
17    pub struct NSArchiver;
18);
19
20#[cfg(feature = "NSCoder")]
21extern_conformance!(
22    unsafe impl NSObjectProtocol for NSArchiver {}
23);
24
25#[cfg(feature = "NSCoder")]
26impl NSArchiver {
27    extern_methods!(
28        #[cfg(feature = "NSData")]
29        #[deprecated = "Use NSKeyedArchiver instead"]
30        #[unsafe(method(initForWritingWithMutableData:))]
31        #[unsafe(method_family = init)]
32        pub fn initForWritingWithMutableData(
33            this: Allocated<Self>,
34            mdata: &NSMutableData,
35        ) -> Retained<Self>;
36
37        #[cfg(feature = "NSData")]
38        #[deprecated = "Use NSKeyedArchiver instead"]
39        #[unsafe(method(archiverData))]
40        #[unsafe(method_family = none)]
41        pub fn archiverData(&self) -> Retained<NSMutableData>;
42
43        /// # Safety
44        ///
45        /// `root_object` should be of the correct type.
46        #[deprecated = "Use NSKeyedArchiver instead"]
47        #[unsafe(method(encodeRootObject:))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn encodeRootObject(&self, root_object: &AnyObject);
50
51        /// # Safety
52        ///
53        /// `object` should be of the correct type.
54        #[deprecated = "Use NSKeyedArchiver instead"]
55        #[unsafe(method(encodeConditionalObject:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn encodeConditionalObject(&self, object: Option<&AnyObject>);
58
59        #[cfg(feature = "NSData")]
60        /// # Safety
61        ///
62        /// `root_object` should be of the correct type.
63        #[deprecated = "Use NSKeyedArchiver instead"]
64        #[unsafe(method(archivedDataWithRootObject:))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn archivedDataWithRootObject(root_object: &AnyObject) -> Retained<NSData>;
67
68        #[cfg(feature = "NSString")]
69        /// # Safety
70        ///
71        /// `root_object` should be of the correct type.
72        #[deprecated = "Use NSKeyedArchiver instead"]
73        #[unsafe(method(archiveRootObject:toFile:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn archiveRootObject_toFile(root_object: &AnyObject, path: &NSString) -> bool;
76
77        #[cfg(feature = "NSString")]
78        #[deprecated = "Use NSKeyedArchiver instead"]
79        #[unsafe(method(encodeClassName:intoClassName:))]
80        #[unsafe(method_family = none)]
81        pub fn encodeClassName_intoClassName(
82            &self,
83            true_name: &NSString,
84            in_archive_name: &NSString,
85        );
86
87        #[cfg(feature = "NSString")]
88        #[deprecated = "Use NSKeyedArchiver instead"]
89        #[unsafe(method(classNameEncodedForTrueClassName:))]
90        #[unsafe(method_family = none)]
91        pub fn classNameEncodedForTrueClassName(
92            &self,
93            true_name: &NSString,
94        ) -> Option<Retained<NSString>>;
95
96        /// # Safety
97        ///
98        /// - `object` should be of the correct type.
99        /// - `new_object` should be of the correct type.
100        #[deprecated = "Use NSKeyedArchiver instead"]
101        #[unsafe(method(replaceObject:withObject:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn replaceObject_withObject(&self, object: &AnyObject, new_object: &AnyObject);
104    );
105}
106
107/// Methods declared on superclass `NSObject`.
108#[cfg(feature = "NSCoder")]
109impl NSArchiver {
110    extern_methods!(
111        #[unsafe(method(init))]
112        #[unsafe(method_family = init)]
113        pub fn init(this: Allocated<Self>) -> Retained<Self>;
114
115        #[unsafe(method(new))]
116        #[unsafe(method_family = new)]
117        pub fn new() -> Retained<Self>;
118    );
119}
120
121#[cfg(feature = "NSCoder")]
122impl DefaultRetained for NSArchiver {
123    #[inline]
124    fn default_retained() -> Retained<Self> {
125        Self::new()
126    }
127}
128
129extern_class!(
130    /// **********        Archiving: Reading        ***************
131    ///
132    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunarchiver?language=objc)
133    #[unsafe(super(NSCoder, NSObject))]
134    #[derive(Debug, PartialEq, Eq, Hash)]
135    #[cfg(feature = "NSCoder")]
136    #[deprecated = "Use NSKeyedUnarchiver instead"]
137    pub struct NSUnarchiver;
138);
139
140#[cfg(feature = "NSCoder")]
141extern_conformance!(
142    unsafe impl NSObjectProtocol for NSUnarchiver {}
143);
144
145#[cfg(feature = "NSCoder")]
146impl NSUnarchiver {
147    extern_methods!(
148        #[cfg(feature = "NSData")]
149        #[deprecated = "Use NSKeyedUnarchiver instead"]
150        #[unsafe(method(initForReadingWithData:))]
151        #[unsafe(method_family = init)]
152        pub unsafe fn initForReadingWithData(
153            this: Allocated<Self>,
154            data: &NSData,
155        ) -> Option<Retained<Self>>;
156
157        #[cfg(feature = "NSZone")]
158        /// # Safety
159        ///
160        /// `zone` must be a valid pointer or null.
161        #[deprecated = "Use NSKeyedUnarchiver instead"]
162        #[unsafe(method(setObjectZone:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn setObjectZone(&self, zone: *mut NSZone);
165
166        #[cfg(feature = "NSZone")]
167        #[deprecated = "Use NSKeyedUnarchiver instead"]
168        #[unsafe(method(objectZone))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn objectZone(&self) -> *mut NSZone;
171
172        #[deprecated = "Use NSKeyedUnarchiver instead"]
173        #[unsafe(method(isAtEnd))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn isAtEnd(&self) -> bool;
176
177        #[deprecated = "Use NSKeyedUnarchiver instead"]
178        #[unsafe(method(systemVersion))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn systemVersion(&self) -> c_uint;
181
182        #[cfg(feature = "NSData")]
183        #[deprecated = "Use NSKeyedUnarchiver instead"]
184        #[unsafe(method(unarchiveObjectWithData:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn unarchiveObjectWithData(data: &NSData) -> Option<Retained<AnyObject>>;
187
188        #[cfg(feature = "NSString")]
189        #[deprecated = "Use NSKeyedUnarchiver instead"]
190        #[unsafe(method(unarchiveObjectWithFile:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn unarchiveObjectWithFile(path: &NSString) -> Option<Retained<AnyObject>>;
193
194        #[cfg(feature = "NSString")]
195        #[deprecated = "Use NSKeyedUnarchiver instead"]
196        #[unsafe(method(decodeClassName:asClassName:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn decodeClassName_asClassName_class(
199            in_archive_name: &NSString,
200            true_name: &NSString,
201        );
202
203        #[cfg(feature = "NSString")]
204        #[deprecated = "Use NSKeyedUnarchiver instead"]
205        #[unsafe(method(decodeClassName:asClassName:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn decodeClassName_asClassName(
208            &self,
209            in_archive_name: &NSString,
210            true_name: &NSString,
211        );
212
213        #[cfg(feature = "NSString")]
214        #[deprecated = "Use NSKeyedUnarchiver instead"]
215        #[unsafe(method(classNameDecodedForArchiveClassName:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn classNameDecodedForArchiveClassName_class(
218            in_archive_name: &NSString,
219        ) -> Retained<NSString>;
220
221        #[cfg(feature = "NSString")]
222        #[deprecated = "Use NSKeyedUnarchiver instead"]
223        #[unsafe(method(classNameDecodedForArchiveClassName:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn classNameDecodedForArchiveClassName(
226            &self,
227            in_archive_name: &NSString,
228        ) -> Retained<NSString>;
229
230        /// # Safety
231        ///
232        /// - `object` should be of the correct type.
233        /// - `new_object` should be of the correct type.
234        #[deprecated = "Use NSKeyedUnarchiver instead"]
235        #[unsafe(method(replaceObject:withObject:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn replaceObject_withObject(&self, object: &AnyObject, new_object: &AnyObject);
238    );
239}
240
241/// Methods declared on superclass `NSObject`.
242#[cfg(feature = "NSCoder")]
243impl NSUnarchiver {
244    extern_methods!(
245        #[unsafe(method(init))]
246        #[unsafe(method_family = init)]
247        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
248
249        #[unsafe(method(new))]
250        #[unsafe(method_family = new)]
251        pub unsafe fn new() -> Retained<Self>;
252    );
253}
254
255mod private_NSObjectNSArchiverCallback {
256    pub trait Sealed {}
257}
258
259/// Category "NSArchiverCallback" on [`NSObject`].
260///
261/// **********        Object call back        ***************
262#[doc(alias = "NSArchiverCallback")]
263pub unsafe trait NSObjectNSArchiverCallback:
264    ClassType + Sized + private_NSObjectNSArchiverCallback::Sealed
265{
266    extern_methods!(
267        #[unsafe(method(classForArchiver))]
268        #[unsafe(method_family = none)]
269        fn classForArchiver(&self) -> Option<&'static AnyClass>;
270
271        #[cfg(feature = "NSCoder")]
272        #[deprecated]
273        #[unsafe(method(replacementObjectForArchiver:))]
274        #[unsafe(method_family = none)]
275        fn replacementObjectForArchiver(
276            &self,
277            archiver: &NSArchiver,
278        ) -> Option<Retained<AnyObject>>;
279    );
280}
281
282impl private_NSObjectNSArchiverCallback::Sealed for NSObject {}
283unsafe impl NSObjectNSArchiverCallback for NSObject {}